From b429440a58c2143fbfe97c27288ad3e048b06507 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 4 Jun 2019 12:59:25 +0200 Subject: [PATCH] decouple JBUIScale and UI initialization logic GitOrigin-RevId: 72cd2f178a2b25d80ffee5bc172e7ac54ada8f9a --- .../regexp/intention/CheckRegExpForm.java | 5 +- .../images/editor/impl/ImageEditorUI.java | 2 +- .../intellij/images/ui/ImageComponent.java | 20 +- .../src/org/intellij/images/vfs/IfsUtil.java | 20 +- .../CompilerModuleOptionsComponent.java | 5 +- .../options/CompilerUIConfigurable.java | 4 +- .../options/TargetOptionsComponent.java | 3 +- .../debugger/memory/ui/InstancesView.java | 12 +- .../scratch/JavaScratchConfigurable.java | 8 +- .../ui/CommonJavaParametersPanel.java | 6 +- .../intellij/execution/ui/JrePathEditor.java | 4 +- .../importProject/RootsDetectionStep.java | 19 +- .../newProjectWizard/SourcePathsStep.java | 7 +- .../ProjectJdkForModuleStep.java | 3 +- .../util/projectWizard/ProjectNameStep.java | 10 +- .../classpath/ClasspathPanelImpl.java | 4 +- .../options/editor/ExcludeTable.java | 4 +- .../intention/impl/CreateClassDialog.java | 8 +- .../UnusedDeclarationPresentation.java | 8 +- .../psi/util/ProjectIconsAccessor.java | 8 +- .../extractMethod/preview/PreviewPanel.java | 6 +- .../InheritanceToDelegationDialog.java | 7 +- .../EnclosingMethodSelectionDialog.java | 20 +- .../InplaceIntroduceParameterPopup.java | 20 +- .../IntroduceParameterSettingsUI.java | 19 +- .../MakeParameterizedStaticDialog.java | 7 +- .../makeStatic/SimpleMakeStaticDialog.java | 6 +- .../refactoring/typeCook/TypeCookDialog.java | 6 +- .../HighlightDisplayLevel.java | 8 +- platform/core-ui/src/ui/LayeredIcon.java | 22 +- platform/core-ui/src/ui/OffsetIcon.java | 4 +- platform/core-ui/src/ui/RowIcon.java | 6 +- platform/core-ui/src/util/IconUtil.java | 18 +- .../diff/impl/DiffRequestProcessor.java | 3 +- .../intellij/diff/merge/TextMergeViewer.java | 6 +- .../diff/tools/util/DiffSplitter.java | 6 +- .../intellij/diff/tools/util/StatusPanel.java | 23 +- .../diff/tools/util/ThreeDiffSplitter.java | 20 +- .../com/intellij/diff/util/DiffDrawUtil.java | 4 +- .../util/DiffEmptyHighlighterRenderer.java | 6 +- .../diff/util/DiffLineSeparatorRenderer.java | 22 +- .../src/com/intellij/diff/util/DiffUtil.java | 5 +- .../openapi/diff/impl/dir/DirDiffPanel.java | 33 +- .../vcs/ex/LineStatusMarkerRenderer.java | 24 +- .../com/intellij/dvcs/push/ui/PushLog.java | 6 +- .../intellij/ide/ui/NotRoamableUiSettings.kt | 3 +- .../src/com/intellij/ide/ui/UISettings.kt | 22 +- .../com/intellij/ide/ui/UISettingsState.kt | 6 +- .../options/EditorFontsConstants.java | 30 +- .../AbstractExternalSystemConfigurable.java | 6 +- .../intellij/codeInspection/ui/ListTable.java | 6 +- .../execution/runners/ExecutionUtil.java | 6 +- .../dialog/VcsScopeItemPresenter.java | 8 +- .../options/codeStyle/RightMarginForm.java | 20 +- .../ExcludedFilesPatternForm.java | 6 +- .../excludedFiles/ExcludedFilesScopeForm.java | 6 +- .../options/colors/ColorSchemeActions.java | 6 +- .../fileStatus/FileStatusColorsPanel.java | 22 +- .../fileStatus/FileStatusColorsTable.java | 21 +- .../colors/pluginExport/PluginInfoForm.java | 21 +- .../impl/DaemonTooltipWithActionRenderer.kt | 7 +- .../daemon/impl/HectorComponent.java | 3 +- .../documentation/DocumentationComponent.java | 15 +- .../codeInsight/lookup/impl/Advertiser.java | 19 +- .../lookup/impl/LookupCellRenderer.java | 3 +- .../codeInsight/lookup/impl/LookupImpl.java | 4 +- .../preview/ImagePreviewComponent.java | 25 +- .../impl/LiveTemplateSettingsEditor.java | 3 +- .../codeInspection/ex/QuickFixAction.java | 6 +- .../AbstractNamingConventionInspection.java | 3 +- .../codeInspection/ui/InspectionNodeInfo.java | 11 +- .../ui/InspectionViewNavigationPanel.java | 19 +- .../RunConfigurationsComboBoxAction.java | 3 +- .../actions/ShowRunningListAction.java | 3 +- .../console/ConsoleConfigurable.java | 6 +- .../console/ConsoleGutterComponent.java | 20 +- .../execution/impl/BeforeRunStepsPanel.java | 4 +- .../impl/SingleConfigurationConfigurable.java | 5 +- .../runners/RerunTestsNotification.java | 19 +- .../ui/layout/impl/RunnerContentUi.java | 12 +- .../src/com/intellij/find/FindAllAction.java | 6 +- .../intellij/find/SearchReplaceComponent.java | 3 +- .../src/com/intellij/find/SearchTextArea.java | 23 +- .../actions/CompositeActiveComponent.java | 20 +- .../actions/ShowUsagesTableCellRenderer.java | 24 +- .../intellij/find/impl/FindPopupPanel.java | 13 +- .../find/impl/FindPopupScopeUIImpl.java | 6 +- .../com/intellij/ide/actions/BigPopupUI.java | 7 +- .../ide/actions/SearchEverywhereAction.java | 17 +- .../CreateWithTemplatesDialogPanel.java | 11 +- .../RunConfigurationsSEContributor.java | 5 +- .../searcheverywhere/SearchEverywhereUI.java | 10 +- .../com/intellij/ide/bookmarks/Bookmark.java | 18 +- .../impl/AllFileTemplatesConfigurable.java | 3 +- .../impl/FileTemplateConfigurable.java | 7 +- .../ide/navigationToolbar/NavBarActions.java | 6 +- .../ide/navigationToolbar/NavBarPanel.java | 5 +- .../navigationToolbar/NavBarUpdateQueue.java | 20 +- .../navigationToolbar/ShowNavBarAction.java | 20 +- .../ui/AbstractNavBarUI.java | 17 +- .../impl/FileNestingInProjectViewDialog.java | 9 +- .../todo/configurable/TodoConfigurable.java | 4 +- .../intellij/ide/util/FileStructurePopup.java | 5 +- .../ide/util/gotoByName/ChooseByNameBase.java | 3 +- .../util/scopeChooser/ScopeChooserCombo.java | 4 +- .../CommonContentEntriesEditor.java | 3 +- .../configuration/ContentEntryTreeEditor.java | 5 +- .../ui/SingleInspectionProfilePanel.java | 8 +- .../InspectionsConfigTreeTable.java | 6 +- .../inline/InlineOptionsDialog.java | 18 +- ...InlineOptionsWithSearchSettingsDialog.java | 23 +- .../safeDelete/SafeDeleteDialog.java | 5 +- .../com/intellij/ui/tabs/ColorButtonBase.java | 6 +- .../packaging/ManagePackagesDialog.java | 12 +- .../src/com/intellij/ide/HelpTooltip.java | 23 +- .../actionSystem/ex/CheckboxAction.java | 8 +- .../actionSystem/ex/ComboBoxAction.java | 17 +- .../src/com/intellij/openapi/ui/ComboBox.java | 53 +- .../openapi/ui/ComboBoxTableRenderer.java | 5 +- .../openapi/ui/ComponentValidator.java | 10 +- .../intellij/openapi/ui/DialogWrapper.java | 8 +- .../src/com/intellij/openapi/ui/Messages.java | 4 +- .../intellij/openapi/ui/OnePixelDivider.java | 4 +- .../openapi/ui/ThreeComponentsSplitter.java | 24 +- .../ui/cellvalidators/CellTooltipManager.java | 5 +- .../ui/panel/ComponentPanelBuilder.java | 3 +- .../openapi/util/DimensionService.java | 12 +- .../src/com/intellij/ui/AnActionButton.java | 4 +- .../src/com/intellij/ui/AnimatedIcon.java | 2 +- .../intellij/ui/ColoredListCellRenderer.java | 6 +- .../intellij/ui/EditorNotificationPanel.java | 25 +- .../src/com/intellij/ui/GuiUtils.java | 60 +- .../src/com/intellij/ui/SearchTextField.java | 4 +- .../intellij/ui/SimpleColoredComponent.java | 7 +- .../ui/components/DefaultScrollBarUI.java | 20 +- .../intellij/ui/components/JBScrollBar.java | 4 +- .../intellij/ui/components/JBScrollPane.java | 4 +- .../intellij/ui/components/JBTextArea.java | 6 +- .../intellij/ui/components/JBViewport.java | 7 +- .../ui/components/MacScrollBarUI.java | 3 +- .../intellij/ui/components/OnOffButton.java | 30 +- .../components/breadcrumbs/Breadcrumbs.java | 9 +- .../fields/ExtendableTextComponent.java | 7 +- .../ui/components/labels/DropDownLink.java | 11 +- .../intellij/ui/paint/EffectPainter2D.java | 27 +- .../src/com/intellij/ui/table/JBTable.java | 3 +- .../src/com/intellij/ui/tabs/TabsUtil.java | 3 +- .../com/intellij/ui/tabs/impl/JBTabsImpl.java | 5 +- .../com/intellij/ui/tabs/impl/TabLabel.java | 7 +- .../CompressibleSingleRowLayout.java | 4 +- .../intellij/ui/tabs/newImpl/JBTabsImpl.java | 7 +- .../intellij/ui/tabs/newImpl/TabLabel.java | 5 +- .../CompressibleSingleRowLayout.java | 6 +- .../ui/treeStructure/treetable/TreeTable.java | 21 +- .../util/ui/ButtonlessScrollBarUI.java | 10 +- .../src/com/intellij/util/ui/StatusText.java | 21 +- .../com/intellij/util/ui/tree/TreeUtil.java | 8 +- .../AbstractDescriptionAwareSchemesPanel.java | 20 +- .../options/schemes/EditableSchemesCombo.java | 8 +- .../hint/EditorFragmentComponent.java | 21 +- .../intellij/diagnostic/IdeErrorsDialog.java | 5 +- .../src/com/intellij/ide/IdeEventQueue.java | 12 +- .../com/intellij/ide/IdeTooltipManager.java | 7 +- .../com/intellij/ide/actions/AboutPopup.java | 13 +- .../ide/actions/RecentLocationsAction.java | 11 +- .../ide/actions/SwitchBootJdkAction.java | 4 +- .../com/intellij/ide/actions/Switcher.java | 9 +- .../SwitcherToolWindowsListRenderer.java | 6 +- .../actions/TogglePresentationModeAction.java | 16 +- .../intellij/ide/gdpr/ConsentSettingsUi.java | 17 +- .../intellij/ide/plugins/CountComponent.java | 9 +- .../ide/plugins/PluginHostsConfigurable.java | 5 +- .../plugins/PluginManagerConfigurableNew.java | 7 +- .../PluginManagerConfigurableNewLayout.java | 10 +- ...PluginManagerConfigurableTreeRenderer.java | 6 +- .../ide/plugins/PluginManagerMain.java | 7 +- .../com/intellij/ide/plugins/PluginTable.java | 6 +- .../com/intellij/ide/plugins/TagPanel.java | 3 +- .../ide/plugins/newui/BackButton.java | 12 +- .../plugins/newui/CellPluginComponent.java | 6 +- .../ide/plugins/newui/ColorButton.java | 6 +- .../newui/DetailsPagePluginComponent.java | 17 +- .../ide/plugins/newui/EventHandler.java | 3 +- .../newui/GridCellPluginComponent.java | 11 +- .../plugins/newui/HiDPIPluginLogoIcon.java | 6 +- .../ide/plugins/newui/LineFunction.java | 6 +- .../plugins/newui/ListPluginComponent.java | 5 +- .../plugins/newui/NewListPluginComponent.java | 9 +- .../newui/PluginDetailsPageComponent.java | 17 +- .../plugins/newui/PluginSearchTextField.java | 6 +- .../ide/plugins/newui/PluginsGridLayout.java | 14 +- .../plugins/newui/PluginsGroupComponent.java | 7 +- .../ide/plugins/newui/PluginsTab.java | 9 +- .../ide/plugins/newui/SearchPopup.java | 9 +- .../ide/plugins/newui/TabHeaderComponent.java | 13 +- .../DisplayTroubleInfoCollector.java | 4 +- .../ide/ui/AppearanceConfigurable.java | 6 +- .../intellij/ide/ui/ColorBlindnessPanel.java | 22 +- .../intellij/ide/ui/RoundedActionButton.java | 14 +- .../src/com/intellij/ide/ui/laf/IdeaLaf.java | 10 +- .../intellij/ide/ui/laf/LafManagerImpl.java | 11 +- .../ide/ui/laf/darcula/DarculaLaf.java | 5 +- .../ide/ui/laf/darcula/DarculaUIUtil.java | 41 +- .../ui/laf/darcula/ui/DarculaButtonUI.java | 7 +- .../laf/darcula/ui/DarculaCheckBoxBorder.java | 6 +- .../ui/laf/darcula/ui/DarculaCheckBoxUI.java | 12 +- .../ui/laf/darcula/ui/DarculaComboBoxUI.java | 11 +- .../ui/DarculaEditorTextFieldBorder.java | 23 +- .../darcula/ui/DarculaPasswordFieldUI.java | 4 +- .../darcula/ui/DarculaPopupMenuBorder.java | 20 +- .../laf/darcula/ui/DarculaProgressBarUI.java | 14 +- .../laf/darcula/ui/DarculaRadioButtonUI.java | 5 +- .../ui/laf/darcula/ui/DarculaSpinnerUI.java | 33 +- .../ui/laf/darcula/ui/DarculaTextBorder.java | 5 +- .../ui/laf/darcula/ui/DarculaTextFieldUI.java | 10 +- .../ui/TextFieldWithPopupHandlerUI.java | 13 +- .../ui/laf/intellij/IntelliJCheckBoxUI.java | 5 +- .../laf/intellij/MacIntelliJButtonBorder.java | 6 +- .../laf/intellij/MacIntelliJCheckBoxUI.java | 25 +- .../intellij/MacIntelliJRadioButtonUI.java | 5 +- .../ui/laf/intellij/MacIntelliJSpinnerUI.java | 5 +- .../laf/intellij/MacIntelliJTextBorder.java | 6 +- .../laf/intellij/MacIntelliJTextFieldUI.java | 10 +- .../ui/laf/intellij/WinIntelliJButtonUI.java | 19 +- .../laf/intellij/WinIntelliJCheckBoxUI.java | 11 +- .../laf/intellij/WinIntelliJComboBoxUI.java | 10 +- .../ui/laf/intellij/WinIntelliJSliderUI.java | 58 +- .../ui/laf/intellij/WinIntelliJSpinnerUI.java | 19 +- .../laf/intellij/WinIntelliJTextFieldUI.java | 32 +- .../ide/ui/laf/intellij/WinOnOffButtonUI.java | 19 +- .../src/com/intellij/ide/util/TipUIUtil.java | 11 +- .../src/com/intellij/idea/StartupUtil.java | 9 +- .../intellij/internal/GrayFilterConfig.java | 5 +- .../src/com/intellij/internal/HidpiInfo.java | 62 +- .../internal/focus/FocusDebuggerAction.java | 8 +- .../internal/focus/FocusTracesDialog.java | 30 +- .../inspector/ApplyWindowSizeAction.java | 4 +- .../internal/inspector/UiDropperAction.java | 7 +- .../internal/inspector/UiInspectorAction.java | 21 +- .../fus/ui/HiDPIModeUsagesCollector.java | 6 +- .../fus/ui/ScaleInfoUsageCollector.java | 6 +- .../com/intellij/internal/tree/ExpandAll.java | 20 +- .../internal/ui/ComponentPanelTestAction.java | 11 +- .../EventLogToolWindowFactory.java | 8 +- .../impl/IdeNotificationArea.java | 8 +- .../impl/NotificationsManagerImpl.java | 13 +- .../ui/NotificationsConfigurablePanel.java | 4 +- .../notification/impl/ui/StickyButtonUI.java | 6 +- .../actionSystem/SplitButtonAction.java | 15 +- .../actionSystem/impl/ActionButton.java | 14 +- .../openapi/actionSystem/impl/ActionMenu.java | 5 +- .../impl/ActionPopupMenuImpl.java | 6 +- .../actionSystem/impl/ActionToolbarImpl.java | 13 +- .../editor/actions/ContentChooser.java | 10 +- .../editor/impl/AccessibleGutterLine.java | 8 +- .../impl/EditorGutterComponentImpl.java | 14 +- .../openapi/editor/impl/EditorImpl.java | 3 +- .../editor/impl/EditorMarkupModelImpl.java | 21 +- .../openapi/editor/impl/ImmediatePainter.java | 6 +- .../editor/impl/view/EditorPainter.java | 62 +- .../view/VisualLineFragmentsIterator.java | 29 +- .../fileEditor/impl/EditorComposite.java | 9 +- .../impl/EditorTabbedContainer.java | 7 +- .../openapi/fileEditor/impl/EditorWindow.java | 4 +- .../impl/FileEditorManagerImpl.java | 4 +- .../impl/ReopenClosedTabAction.java | 21 +- .../keyGestures/KeyboardGestureProcessor.java | 7 +- .../openapi/keymap/impl/ui/ActionsTree.java | 8 +- .../impl/ui/ShortcutFilteringPanel.java | 21 +- .../newEditor/CopySettingsPathAction.kt | 10 +- .../options/newEditor/SettingsTreeView.java | 9 +- .../options/newEditor/SimpleBanner.java | 5 +- .../newEditor/SingleSettingEditor.java | 5 +- .../openapi/progress/util/ProgressDialog.java | 4 +- .../ui/impl/DialogWrapperPeerImpl.java | 9 +- .../openapi/ui/impl/ShadowPainter.java | 16 +- .../updateSettings/impl/UpdateInfoDialog.java | 3 +- .../openapi/util/WindowStateServiceImpl.java | 11 +- .../openapi/wm/impl/FocusManagerImpl.java | 3 +- .../openapi/wm/impl/IdeFrameImpl.java | 8 +- .../intellij/openapi/wm/impl/IdeRootPane.java | 7 +- .../openapi/wm/impl/PaintersHelper.java | 5 +- .../openapi/wm/impl/StripeButtonUI.java | 13 +- .../openapi/wm/impl/ToolWindowIcon.java | 8 +- .../openapi/wm/impl/ToolWindowImpl.java | 8 +- .../wm/impl/ToolWindowManagerImpl.java | 3 +- .../openapi/wm/impl/ToolWindowsPane.java | 10 +- .../openapi/wm/impl/WindowManagerImpl.java | 11 +- .../wm/impl/content/ContentTabLabel.java | 11 +- .../wm/impl/content/TabContentLayout.java | 3 +- .../CustomFrameTitleButtons.kt | 4 +- .../header/CustomHeader.kt | 13 +- .../header/FrameHeader.kt | 15 +- .../wm/impl/status/IdeStatusBarImpl.java | 7 +- .../wm/impl/status/InfoAndProgressPanel.java | 7 +- .../wm/impl/status/MemoryUsagePanel.java | 7 +- .../status/PresentationModeProgressPanel.java | 5 +- .../openapi/wm/impl/status/TextPanel.java | 6 +- .../wm/impl/status/ToolWindowsWidget.java | 3 +- .../impl/welcomeScreen/FlatWelcomeFrame.java | 9 +- .../welcomeScreen/NewRecentProjectPanel.java | 16 +- .../welcomeScreen/RecentProjectPanel.java | 16 +- .../WelcomeBalloonLayoutImpl.java | 18 +- .../ui/AbstractExpandableItemsHandler.java | 8 +- .../src/com/intellij/ui/AppUIUtil.java | 17 +- .../src/com/intellij/ui/BalloonImpl.java | 46 +- .../ui/BalloonLayoutConfiguration.java | 23 +- .../intellij/ui/ComboboxEditorTextField.java | 2 +- .../src/com/intellij/ui/EditorTextField.java | 5 +- .../com/intellij/ui/FinderRecursivePanel.java | 6 +- .../src/com/intellij/ui/GotItMessage.java | 21 +- .../src/com/intellij/ui/GotItPanel.java | 24 +- .../com/intellij/ui/ScrollPaneActions.java | 24 +- .../src/com/intellij/ui/Splash.java | 10 +- .../com/intellij/ui/SwingActionDelegate.java | 6 +- .../ui/colorpicker/CommonButtonUI.java | 4 +- .../ui/components/LegalNoticeDialog.java | 5 +- .../intellij/ui/javafx/JFXPanelWrapper.java | 10 +- .../intellij/ui/javafx/JavaFxHtmlPanel.java | 6 +- .../ui/layout/migLayout/MigLayoutBuilder.kt | 9 +- .../com/intellij/ui/plaf/beg/IdeaMenuUI.java | 6 +- .../com/intellij/ui/popup/AbstractPopup.java | 9 +- .../src/com/intellij/ui/stripe/Updater.java | 6 +- .../intellij/ui/tree/ui/ClassicPainter.java | 19 +- .../intellij/ui/tree/ui/CompactPainter.java | 21 +- .../src/com/intellij/util/ui/SwingHelper.java | 9 +- .../intellij/util/ui/table/JBListTable.java | 6 +- .../paint/EffectPainter2DThicknessTest.java | 20 +- .../ui/tree/ui/TreeControlPainterTest.java | 20 +- .../util/ui/CompositeIconPaintTestHelper.java | 9 +- .../com/intellij/util/ui/DrawImageTest.java | 20 +- .../intellij/util/ui/EmptyIconScaleTest.java | 11 +- .../com/intellij/util/ui/IconScaleTest.java | 17 +- .../com/intellij/util/ui/JBValueTest.java | 43 +- .../util/ui/LayeredIconPaintTest.java | 9 +- .../intellij/util/ui/OffsetIconPaintTest.java | 6 +- .../intellij/util/ui/RowIconPaintTest.java | 6 +- .../intellij/util/ui/SvgIconPaintTest.java | 9 +- .../com/intellij/util/ui/SvgIconSizeTest.java | 17 +- .../com/intellij/util/ui/TestScaleHelper.java | 30 +- .../intellij/util/ui/TextToIconPaintTest.java | 14 +- .../util/ui/paint/AbstractPainter2DTest.java | 17 +- .../util/ui/paint/LinePainter2DTest.java | 30 +- .../intellij/util/ui/paint/PaintUtilTest.java | 5 +- .../util/ui/paint/RectanglePainter2DTest.java | 44 +- .../util/ui/standalone/HidpiPropTest.java | 8 +- .../Java2DUiScaleDisabledPropTest.java | 6 +- .../Java2DUiScaleEnabledPropTest.java | 10 +- .../util/ui/standalone/UserScalePropTest.java | 8 +- .../plugin/ui/ScopePanel.java | 3 +- .../testFramework/TestRunnerUtil.java | 10 +- .../recorder/ui/GuiScriptEditorPanel.java | 3 +- .../com/intellij/util/LazyInitializer.java | 95 +- .../com/intellij/openapi/util/IconLoader.java | 99 +-- .../ui/src/com/intellij/ui/ColorUtil.java | 5 +- .../ui/src/com/intellij/ui/ComponentUtil.java | 71 ++ .../src/com/intellij/ui/JBAutoscroller.java | 5 +- .../util/ui/src/com/intellij/ui/JBColor.java | 38 +- .../ui/src/com/intellij/ui/JreHiDpiUtil.java | 98 +++ .../ui/src/com/intellij/ui/SizedIcon.java | 4 +- .../ui/src/com/intellij/ui/TableUtil.java | 3 +- .../ui/src/com/intellij/ui/TitlePanel.java | 7 +- .../com/intellij/ui/components/JBPanel.java | 6 +- .../com/intellij/ui/icons}/CopyableIcon.java | 4 +- .../intellij/ui/icons/DarkIconProvider.java | 8 + .../com/intellij/ui/icons/LazyImageIcon.java | 81 ++ .../ui/icons/MenuBarIconProvider.java | 9 + .../com/intellij/ui/paint/LinePainter2D.java | 8 +- .../src/com/intellij/ui/paint/PaintUtil.java | 12 +- .../intellij/ui/paint/RectanglePainter2D.java | 4 +- .../ui/scale/AbstractScaleContextAware.java | 41 + .../intellij/ui/scale/DerivedScaleType.java | 36 + .../src/com/intellij/ui/scale/JBUIScale.java | 356 ++++++++ .../ui/src/com/intellij/ui/scale/Scale.java | 56 ++ .../com/intellij/ui/scale/ScaleContext.java | 221 +++++ .../intellij/ui/scale/ScaleContextAware.java | 45 + .../ui/scale/ScaleContextSupport.java | 11 + .../src/com/intellij/ui/scale/ScaleType.java | 91 ++ .../ui/src/com/intellij/ui/scale/Scaler.java | 51 ++ .../intellij/ui/scale/UserScaleContext.java | 290 +++++++ .../ui/scale/UserScaleContextSupport.java | 11 + .../ui/src/com/intellij/util/ImageLoader.java | 14 +- .../com/intellij/util/JBHiDPIScaledImage.java | 12 +- .../ui/src/com/intellij/util/RetinaImage.java | 2 +- .../ui/src/com/intellij/util/SVGLoader.java | 10 +- .../src/com/intellij/util/ui/ColorsIcon.java | 3 +- .../com/intellij/util/ui/DetectRetinaKit.java | 113 +++ .../src/com/intellij/util/ui/EmptyIcon.java | 26 +- .../src/com/intellij/util/ui/ImageUtil.java | 4 +- .../util/ui/JBCachingScalableIcon.java | 4 +- .../src/com/intellij/util/ui/JBDimension.java | 11 +- .../ui/src/com/intellij/util/ui/JBFont.java | 24 +- .../com/intellij/util/ui/JBHtmlEditorKit.java | 4 + .../ui/src/com/intellij/util/ui/JBInsets.java | 17 +- .../ui/src/com/intellij/util/ui/JBPoint.java | 3 +- .../src/com/intellij/util/ui/JBRectangle.java | 12 +- .../com/intellij/util/ui/JBScalableIcon.java | 17 +- .../ui/src/com/intellij/util/ui/JBUI.java | 375 ++------ .../src/com/intellij/util/ui/JBUIScale.java | 819 ------------------ .../ui/src/com/intellij/util/ui/JBValue.java | 15 +- .../com/intellij/util/ui/StartupUiUtil.java | 203 +---- .../ui/src/com/intellij/util/ui/UIUtil.java | 325 +------ .../util/ui/components/BorderLayoutPanel.java | 4 +- .../util/ui/tree/WideSelectionTreeUI.java | 4 +- .../lst/SimpleLocalChangeListDiffViewer.java | 3 +- .../patch/tool/ApplyPatchMergeTool.java | 20 +- .../changes/ui/ChangeListChooserPanel.java | 5 +- .../changes/ui/CommitChangeListDialog.java | 3 +- .../vcs/log/ui/frame/CommitPanel.java | 5 +- .../vcs/log/ui/frame/DetailsPanel.java | 3 +- .../vcs/log/ui/frame/ProgressStripeIcon.java | 16 +- .../vcs/log/ui/frame/ReferencesPanel.java | 20 +- .../ui/render/GraphCommitCellRenderer.java | 7 +- .../intellij/vcs/log/ui/render/LabelIcon.java | 20 +- .../vcs/log/ui/render/LabelIconCache.kt | 6 +- .../vcs/log/ui/render/LabelPainter.java | 4 +- .../log/ui/render/TooltipReferencesPanel.java | 20 +- .../log/ui/table/GraphTableController.java | 24 +- .../vcs/log/ui/table/RootCellRenderer.java | 24 +- .../vcs/log/ui/table/VcsLogGraphTable.java | 17 +- .../xdebugger/impl/XDebuggerInlayUtil.java | 20 +- .../breakpoints/ui/BreakpointsDialog.java | 5 +- .../xdebugger/impl/ui/BreakpointEditor.java | 20 +- .../xdebugger/memory/ui/ClassesTable.java | 12 +- .../ant/validation/AntHectorConfigurable.java | 19 +- .../coverage/view/CoverageViewManager.java | 6 +- .../git4idea/conflicts/GitConflictsView.kt | 3 +- .../git4idea/push/GitPushOptionsPanel.java | 19 +- .../src/git4idea/push/GitPushTargetPanel.java | 3 +- .../CachingGithubAvatarIconsProvider.kt | 8 +- .../pullrequest/ui/GithubPullRequestsList.kt | 3 +- .../plugins/github/util/GithubImageResizer.kt | 6 +- .../streams/ui/impl/CollectionView.java | 5 +- .../debugger/streams/ui/impl/MappingPane.kt | 5 +- .../idea/svn/difftool/SvnDiffViewer.java | 6 +- .../PropertyInspectorTable.java | 10 +- .../packaging/PyManagePackagesDialog.java | 22 +- .../ui/PyPackageManagementService.java | 8 +- .../breadcrumbs/BreadcrumbsConfigurable.java | 9 +- 439 files changed, 3808 insertions(+), 4430 deletions(-) create mode 100644 platform/util/ui/src/com/intellij/ui/ComponentUtil.java create mode 100644 platform/util/ui/src/com/intellij/ui/JreHiDpiUtil.java rename platform/util/{src/com/intellij/openapi/util => ui/src/com/intellij/ui/icons}/CopyableIcon.java (87%) create mode 100644 platform/util/ui/src/com/intellij/ui/icons/DarkIconProvider.java create mode 100644 platform/util/ui/src/com/intellij/ui/icons/LazyImageIcon.java create mode 100644 platform/util/ui/src/com/intellij/ui/icons/MenuBarIconProvider.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/AbstractScaleContextAware.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/DerivedScaleType.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/JBUIScale.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/Scale.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/ScaleContext.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/ScaleContextAware.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/ScaleContextSupport.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/ScaleType.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/Scaler.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/UserScaleContext.java create mode 100644 platform/util/ui/src/com/intellij/ui/scale/UserScaleContextSupport.java create mode 100644 platform/util/ui/src/com/intellij/util/ui/DetectRetinaKit.java delete mode 100644 platform/util/ui/src/com/intellij/util/ui/JBUIScale.java diff --git a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java index e56e03046e15..3931652b7922 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/intention/CheckRegExpForm.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.lang.regexp.intention; import com.intellij.ide.util.PropertiesComponent; @@ -31,6 +31,7 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.ui.EditorTextField; import com.intellij.ui.JBColor; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -109,7 +110,7 @@ public class CheckRegExpForm { } }; mySampleText.setOneLineMode(false); - int preferredWidth = Math.max(JBUI.scale(250), myRegExp.getPreferredSize().width); + int preferredWidth = Math.max(JBUIScale.scale(250), myRegExp.getPreferredSize().width); myRegExp.setPreferredWidth(preferredWidth); mySampleText.setPreferredWidth(preferredWidth); diff --git a/images/src/org/intellij/images/editor/impl/ImageEditorUI.java b/images/src/org/intellij/images/editor/impl/ImageEditorUI.java index 17e51c8b5a35..3e1346e1fc59 100644 --- a/images/src/org/intellij/images/editor/impl/ImageEditorUI.java +++ b/images/src/org/intellij/images/editor/impl/ImageEditorUI.java @@ -35,10 +35,10 @@ import com.intellij.ui.PopupHandler; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.components.JBLayeredPane; import com.intellij.ui.components.Magnificator; +import com.intellij.ui.scale.ScaleContext; import com.intellij.util.LazyInitializer.NotNullValue; import com.intellij.util.SVGLoader; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.JBUIScale.ScaleContext; import org.intellij.images.ImagesBundle; import org.intellij.images.editor.ImageDocument; import org.intellij.images.editor.ImageDocument.ScaledImageProvider; diff --git a/images/src/org/intellij/images/ui/ImageComponent.java b/images/src/org/intellij/images/ui/ImageComponent.java index b4dbe6a21da3..c7f8170d976d 100644 --- a/images/src/org/intellij/images/ui/ImageComponent.java +++ b/images/src/org/intellij/images/ui/ImageComponent.java @@ -1,22 +1,8 @@ -/* - * Copyright 2000-2009 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.images.ui; +import com.intellij.ui.scale.ScaleContext; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUIScale.ScaleContext; import org.intellij.images.ImagesBundle; import org.intellij.images.editor.ImageDocument; import org.intellij.images.options.GridOptions; @@ -33,7 +19,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.List; -import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; +import static com.intellij.ui.scale.ScaleType.OBJ_SCALE; /** * Image component is draw image box with effects. diff --git a/images/src/org/intellij/images/vfs/IfsUtil.java b/images/src/org/intellij/images/vfs/IfsUtil.java index e2392d22b2de..557400e0eaf0 100644 --- a/images/src/org/intellij/images/vfs/IfsUtil.java +++ b/images/src/org/intellij/images/vfs/IfsUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.images.vfs; import com.intellij.openapi.diagnostic.Logger; @@ -24,10 +10,10 @@ import com.intellij.openapi.util.Ref; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.reference.SoftReference; +import com.intellij.ui.scale.ScaleContext; import com.intellij.util.LogicalRoot; import com.intellij.util.LogicalRootsManager; import com.intellij.util.SVGLoader; -import com.intellij.util.ui.JBUIScale.ScaleContext; import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.common.bytesource.ByteSourceArray; import org.apache.commons.imaging.formats.ico.IcoImageParser; @@ -50,7 +36,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; -import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; +import static com.intellij.ui.scale.ScaleType.OBJ_SCALE; /** * Image loader utility. diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerModuleOptionsComponent.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerModuleOptionsComponent.java index a74e26f1b4cf..3751f711a6ef 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerModuleOptionsComponent.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerModuleOptionsComponent.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.compiler.impl.javaCompiler; import com.intellij.compiler.options.ModuleOptionsTableModel; @@ -9,6 +9,7 @@ import com.intellij.ui.TableSpeedSearch; import com.intellij.ui.TableUtil; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.fields.ExpandableTextField; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; @@ -30,7 +31,7 @@ public class CompilerModuleOptionsComponent extends JPanel { myProject = project; myTable = new JBTable(new ModuleOptionsTableModel()); - myTable.setRowHeight(JBUI.scale(22)); + myTable.setRowHeight(JBUIScale.scale(22)); myTable.getEmptyText().setText("Additional compilation options will be the same for all modules"); TableColumn moduleColumn = myTable.getColumnModel().getColumn(0); diff --git a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java index 635858c38426..3b335f8636e4 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/CompilerUIConfigurable.java @@ -22,10 +22,10 @@ import com.intellij.ui.Gray; import com.intellij.ui.JBColor; import com.intellij.ui.RawCommandLineEditor; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtilRt; import com.intellij.util.execution.ParametersListUtil; -import com.intellij.util.ui.JBUI; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; @@ -331,6 +331,6 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura myResourcePatternsField = new RawCommandLineEditor(ParametersListUtil.COLON_LINE_PARSER, ParametersListUtil.COLON_LINE_JOINER); myResourcePatternsField.setDialogCaption("Resource patterns"); myHeapSizeField = new JTextField(); - myHeapSizeField.setPreferredSize(new Dimension(JBUI.scale(50), myHeapSizeField.getPreferredSize().height)); + myHeapSizeField.setPreferredSize(new Dimension(JBUIScale.scale(50), myHeapSizeField.getPreferredSize().height)); } } diff --git a/java/compiler/impl/src/com/intellij/compiler/options/TargetOptionsComponent.java b/java/compiler/impl/src/com/intellij/compiler/options/TargetOptionsComponent.java index 8037eb5486b7..903e21d50f58 100644 --- a/java/compiler/impl/src/com/intellij/compiler/options/TargetOptionsComponent.java +++ b/java/compiler/impl/src/com/intellij/compiler/options/TargetOptionsComponent.java @@ -9,6 +9,7 @@ import com.intellij.ui.TableSpeedSearch; import com.intellij.ui.TableUtil; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBTextField; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; import com.intellij.util.ArrayUtilRt; import com.intellij.util.ObjectUtils; @@ -57,7 +58,7 @@ public class TargetOptionsComponent extends JPanel { myCbProjectTargetLevel = createTargetOptionsCombo(); myTable = new JBTable(new ModuleOptionsTableModel()); - myTable.setRowHeight(JBUI.scale(22)); + myTable.setRowHeight(JBUIScale.scale(22)); myTable.getEmptyText().setText("All modules will be compiled with project bytecode version"); TableColumn moduleColumn = myTable.getColumnModel().getColumn(0); diff --git a/java/debugger/impl/src/com/intellij/debugger/memory/ui/InstancesView.java b/java/debugger/impl/src/com/intellij/debugger/memory/ui/InstancesView.java index 0d211aabe9a4..170a02932cdb 100644 --- a/java/debugger/impl/src/com/intellij/debugger/memory/ui/InstancesView.java +++ b/java/debugger/impl/src/com/intellij/debugger/memory/ui/InstancesView.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.debugger.memory.ui; import com.intellij.debugger.DebuggerManager; @@ -9,7 +9,6 @@ import com.intellij.debugger.engine.SuspendContextImpl; import com.intellij.debugger.engine.evaluation.EvaluationContext; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; import com.intellij.debugger.engine.events.DebuggerContextCommandImpl; -import com.intellij.debugger.memory.agent.MemoryAgent; import com.intellij.debugger.memory.agent.MemoryAgentUtil; import com.intellij.debugger.memory.filtering.FilteringResult; import com.intellij.debugger.memory.filtering.FilteringTask; @@ -30,6 +29,7 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.DoubleClickListener; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBPanel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -82,7 +82,7 @@ class InstancesView extends InstancesViewBase { private volatile MyFilteringWorker myFilteringTask = null; InstancesView(@NotNull XDebugSession session, InstancesProvider instancesProvider, String className, Consumer warningMessageConsumer) { - super(new BorderLayout(0, JBUI.scale(BORDER_LAYOUT_DEFAULT_GAP)), session, instancesProvider); + super(new BorderLayout(0, JBUIScale.scale(BORDER_LAYOUT_DEFAULT_GAP)), session, instancesProvider); myClassName = className; myDebugProcess = (DebugProcessImpl) (DebuggerManager.getInstance(session.getProject()).getDebugProcess(session.getDebugProcess().getProcessHandler())); myNodeManager = new MyNodeManager(session.getProject()); @@ -94,11 +94,11 @@ class InstancesView extends InstancesViewBase { editorsProvider, this); final Dimension filteringButtonSize = myFilterConditionEditor.getEditorComponent().getPreferredSize(); - filteringButtonSize.width = JBUI.scale(FILTERING_BUTTON_ADDITIONAL_WIDTH) + - getFilterButton().getPreferredSize().width; + filteringButtonSize.width = JBUIScale.scale(FILTERING_BUTTON_ADDITIONAL_WIDTH) + + getFilterButton().getPreferredSize().width; getFilterButton().setPreferredSize(filteringButtonSize); - final JBPanel filteringPane = new JBPanel(new BorderLayout(JBUI.scale(BORDER_LAYOUT_DEFAULT_GAP), 0)); + final JBPanel filteringPane = new JBPanel(new BorderLayout(JBUIScale.scale(BORDER_LAYOUT_DEFAULT_GAP), 0)); final JBLabel sideEffectsWarning = new JBLabel("Warning: filtering may have side effects", SwingConstants.RIGHT); sideEffectsWarning.setBorder(JBUI.Borders.emptyTop(1)); sideEffectsWarning.setComponentStyle(UIUtil.ComponentStyle.SMALL); diff --git a/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchConfigurable.java b/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchConfigurable.java index 24050a045159..90bb6b1a6157 100644 --- a/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchConfigurable.java +++ b/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchConfigurable.java @@ -1,11 +1,8 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.scratch; import com.intellij.application.options.ModuleDescriptionsComboBox; import com.intellij.execution.ExecutionBundle; -import com.intellij.execution.JavaExecutionUtil; import com.intellij.execution.ui.*; import com.intellij.ide.scratch.ScratchFileService; import com.intellij.ide.scratch.ScratchRootType; @@ -22,6 +19,7 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.components.JBCheckBox; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -103,7 +101,7 @@ public class JavaScratchConfigurable extends SettingsEditor implements PanelWi comboBox.setEditable(true); comboBox.setRenderer(new ColoredListCellRenderer() { { - setIpad(JBUI.insets(1, 0)); + setIpad(JBInsets.create(1, 0)); setMyBorder(null); } diff --git a/java/idea-ui/src/com/intellij/ide/util/importProject/RootsDetectionStep.java b/java/idea-ui/src/com/intellij/ide/util/importProject/RootsDetectionStep.java index 0c0f2581759e..371768b10c47 100644 --- a/java/idea-ui/src/com/intellij/ide/util/importProject/RootsDetectionStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/importProject/RootsDetectionStep.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.util.importProject; import com.intellij.ide.IdeBundle; @@ -24,6 +10,7 @@ import com.intellij.ide.util.projectWizard.importSources.impl.ProjectFromSources import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.ui.MultiLineLabelUI; import com.intellij.openapi.ui.ex.MultiLineLabel; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -76,7 +63,7 @@ public class RootsDetectionStep extends AbstractStepWithProgress { @Override public int getAdditionalWidth() { - return JBUI.scale(12) + AllIcons.General.ArrowDown.getIconWidth(); + return JBUIScale.scale(12) + AllIcons.General.ArrowDown.getIconWidth(); } }; private final Project myProject; diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java index 75ac40b2aae5..8afd97b8fa95 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.intention.impl; import com.intellij.CommonBundle; @@ -32,7 +32,7 @@ import com.intellij.ui.RecentsManager; import com.intellij.ui.ReferenceEditorComboWithBrowseButton; import com.intellij.ui.components.JBLabel; import com.intellij.util.IncorrectOperationException; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBInsets; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -128,7 +128,7 @@ public class CreateClassDialog extends DialogWrapper { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.fill = GridBagConstraints.HORIZONTAL; gbConstraints.anchor = GridBagConstraints.WEST; @@ -136,7 +136,7 @@ public class CreateClassDialog extends DialogWrapper { gbConstraints.weightx = 0; gbConstraints.gridwidth = 1; panel.add(myInformationLabel, gbConstraints); - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.gridx = 1; gbConstraints.weightx = 1; gbConstraints.gridwidth = 1; diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java index a14c774b061e..f595d45d28ae 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java @@ -32,12 +32,12 @@ import com.intellij.psi.util.PropertyUtilBase; import com.intellij.refactoring.safeDelete.SafeDeleteHandler; import com.intellij.ui.HyperlinkAdapter; import com.intellij.ui.ScrollPaneFactory; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ArrayUtil; import com.intellij.util.VisibilityUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.CharArrayUtil; import com.intellij.util.text.DateFormatUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.StartupUiUtil; import com.intellij.util.ui.UIUtil; import org.jdom.Element; @@ -652,9 +652,9 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta } }); final StyleSheet css = ((HTMLEditorKit)htmlView.getEditorKit()).getStyleSheet(); - css.addRule("p.problem-description-group {text-indent: " + JBUI.scale(9) + "px;font-weight:bold;}"); - css.addRule("div.problem-description {margin-left: " + JBUI.scale(9) + "px;}"); - css.addRule("ul {margin-left:" + JBUI.scale(10) + "px;text-indent: 0}"); + css.addRule("p.problem-description-group {text-indent: " + JBUIScale.scale(9) + "px;font-weight:bold;}"); + css.addRule("div.problem-description {margin-left: " + JBUIScale.scale(9) + "px;}"); + css.addRule("ul {margin-left:" + JBUIScale.scale(10) + "px;text-indent: 0}"); css.addRule("code {font-family:" + StartupUiUtil.getLabelFont().getFamily() + "}"); final StringBuffer buf = new StringBuffer(); getComposer().compose(buf, entity, false); diff --git a/java/java-impl/src/com/intellij/psi/util/ProjectIconsAccessor.java b/java/java-impl/src/com/intellij/psi/util/ProjectIconsAccessor.java index 44d210a62963..ccd2261d67b8 100644 --- a/java/java-impl/src/com/intellij/psi/util/ProjectIconsAccessor.java +++ b/java/java-impl/src/com/intellij/psi/util/ProjectIconsAccessor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.util; import com.intellij.openapi.components.ServiceManager; @@ -9,9 +9,9 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.SLRUMap; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -133,8 +133,8 @@ public class ProjectIconsAccessor { } private static boolean hasProperSize(Icon icon) { - return icon.getIconHeight() <= JBUI.scale(ICON_MAX_HEIGHT) && - icon.getIconWidth() <= JBUI.scale(ICON_MAX_WEIGHT); + return icon.getIconHeight() <= JBUIScale.scale(ICON_MAX_HEIGHT) && + icon.getIconWidth() <= JBUIScale.scale(ICON_MAX_WEIGHT); } private static boolean isIdeaProject(@Nullable Project project) { diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/preview/PreviewPanel.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/preview/PreviewPanel.java index f254fae17bfe..6c7cdae204e0 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/preview/PreviewPanel.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/preview/PreviewPanel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.extractMethod.preview; import com.intellij.ide.IdeBundle; @@ -18,10 +18,10 @@ import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.extractMethod.ExtractMethodProcessor; import com.intellij.ui.*; import com.intellij.ui.content.Content; +import com.intellij.ui.scale.JBUIScale; import com.intellij.usages.impl.UsageModelTracker; import com.intellij.util.Alarm; import com.intellij.util.ui.DialogUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.components.BorderLayoutPanel; import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; @@ -173,7 +173,7 @@ class PreviewPanel extends BorderLayoutPanel implements Disposable, DataProvider private boolean myModified; // Accessed in EDT ButtonsPanel(@NotNull Project project) { - super(new FlowLayout(FlowLayout.LEFT, JBUI.scale(8), 0)); + super(new FlowLayout(FlowLayout.LEFT, JBUIScale.scale(8), 0)); myProject = project; myRefactorButton = new JButton(RefactoringBundle.message("refactoring.extract.method.preview.button.refactor")); diff --git a/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java b/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java index e3bfbc9ad2a4..617b3537bc92 100644 --- a/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/inheritanceToDelegation/InheritanceToDelegationDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.inheritanceToDelegation; import com.intellij.openapi.options.ConfigurationException; @@ -18,6 +18,7 @@ import com.intellij.refactoring.ui.NameSuggestionsField; import com.intellij.refactoring.ui.RefactoringDialog; import com.intellij.refactoring.util.classMembers.InterfaceMemberDependencyGraph; import com.intellij.refactoring.util.classMembers.MemberInfo; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -171,7 +172,7 @@ public class InheritanceToDelegationDialog extends RefactoringDialog { gbc.gridy++; gbc.gridwidth = 1; - gbc.insets = JBUI.insets(4, 0); + gbc.insets = JBInsets.create(4, 0); final JLabel fieldNameLabel = new JLabel(); panel.add(fieldNameLabel, gbc); @@ -187,7 +188,7 @@ public class InheritanceToDelegationDialog extends RefactoringDialog { gbc.gridx = 0; gbc.gridy++; gbc.gridwidth = 1; - gbc.insets = JBUI.insets(4, 0); + gbc.insets = JBInsets.create(4, 0); gbc.weightx = 0.0; final JLabel innerClassNameLabel = new JLabel(); panel.add(innerClassNameLabel, gbc); diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/EnclosingMethodSelectionDialog.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/EnclosingMethodSelectionDialog.java index 561da39c65b2..38593637e183 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/EnclosingMethodSelectionDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/EnclosingMethodSelectionDialog.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.introduceParameter; @@ -23,7 +9,7 @@ import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.ui.MethodCellRenderer; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.components.JBList; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBInsets; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -73,7 +59,7 @@ public class EnclosingMethodSelectionDialog extends DialogWrapper { panel.setLayout(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.weighty = 0; gbConstraints.weightx = 1; gbConstraints.gridy = 0; diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java index 52225f3eedf7..f57df51a01d4 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.introduceParameter; import com.intellij.openapi.application.ApplicationManager; @@ -38,7 +24,7 @@ import com.intellij.refactoring.JavaRefactoringSettings; import com.intellij.refactoring.RefactoringActionHandler; import com.intellij.refactoring.ui.TypeSelectorManagerImpl; import com.intellij.ui.JBColor; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBInsets; import gnu.trove.TIntArrayList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -76,7 +62,7 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce myMustBeFinal = mustBeFinal; myWholePanel.add(getPreviewComponent(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, - JBUI.insets(0, 5), 0, 0)); + JBInsets.create(0, 5), 0, 0)); myPanel = new InplaceIntroduceParameterUI(project, localVar, expr, method, parametersToRemove, typeSelectorManager, myOccurrences) { @Override diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterSettingsUI.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterSettingsUI.java index c6503952d320..85eaec8a5a0b 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterSettingsUI.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterSettingsUI.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.introduceParameter; import com.intellij.psi.PsiExpression; @@ -25,6 +11,7 @@ import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.ui.TypeSelectorManager; import com.intellij.ui.NonFocusableCheckBox; import com.intellij.ui.StateRestoringCheckBox; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import gnu.trove.TIntArrayList; @@ -105,7 +92,7 @@ public abstract class IntroduceParameterSettingsUI { JPanel radioButtonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.weighty = 1; gbConstraints.weightx = 1; gbConstraints.gridy = 0; diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java index 0265eacde051..c45749abfca6 100644 --- a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeParameterizedStaticDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.makeStatic; import com.intellij.lang.findUsages.DescriptiveNameUtil; @@ -13,6 +13,7 @@ import com.intellij.refactoring.util.ParameterTablePanel; import com.intellij.refactoring.util.VariableData; import com.intellij.ui.DocumentAdapter; import com.intellij.usageView.UsageViewUtil; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; @@ -113,7 +114,7 @@ public class MakeParameterizedStaticDialog extends AbstractMakeStaticDialog { JPanel panel = new JPanel(new GridBagLayout()); - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.weighty = 0; gbConstraints.weightx = 0; gbConstraints.gridx = 0; @@ -158,7 +159,7 @@ public class MakeParameterizedStaticDialog extends AbstractMakeStaticDialog { gbConstraints.gridwidth = GridBagConstraints.REMAINDER; if(myVariableData.length > 0) { - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.weighty = 0; gbConstraints.weightx = 0; gbConstraints.gridheight = 1; diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java index 3c44ef6c69e3..4034a2d8f782 100644 --- a/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/SimpleMakeStaticDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.makeStatic; import com.intellij.openapi.project.Project; @@ -8,7 +8,7 @@ import com.intellij.refactoring.HelpID; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.util.VariableData; import com.intellij.usageView.UsageViewUtil; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBInsets; import javax.swing.*; import java.awt.*; @@ -58,7 +58,7 @@ public class SimpleMakeStaticDialog extends AbstractMakeStaticDialog { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.weighty = 1; gbConstraints.weightx = 1; gbConstraints.gridy = 0; diff --git a/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java b/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java index f737d5cdfa3e..ed17a40ce53c 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/typeCook/TypeCookDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.typeCook; import com.intellij.lang.findUsages.DescriptiveNameUtil; @@ -10,7 +10,7 @@ import com.intellij.refactoring.JavaRefactoringSettings; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.ui.RefactoringDialog; import com.intellij.usageView.UsageViewUtil; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBInsets; import com.intellij.xml.util.XmlStringUtil; import javax.swing.*; @@ -102,7 +102,7 @@ public class TypeCookDialog extends RefactoringDialog { myCbCookObjects.setText(RefactoringBundle.message("type.cook.generify.objects")); myCbCookToWildcards.setText(RefactoringBundle.message("type.cook.produce.wildcard.types")); - gbConstraints.insets = JBUI.insets(4, 8); + gbConstraints.insets = JBInsets.create(4, 8); gbConstraints.weighty = 1; gbConstraints.weightx = 1; diff --git a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java index dfc9ade2d7b9..8e2a5cd717d3 100644 --- a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java +++ b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java @@ -10,9 +10,9 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.Comparing; import com.intellij.ui.IconManager; import com.intellij.ui.JBColor; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.ColorIcon; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -110,7 +110,7 @@ public class HighlightDisplayLevel { } public static int getEmptyIconDim() { - return JBUI.scale(14); + return JBUIScale.scale(14); } public static Icon createIconByKey(@NotNull TextAttributesKey key) { @@ -178,8 +178,8 @@ public class HighlightDisplayLevel { @Override public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(getColor()); - int shift = JBUI.scale(2); - int size = JBUI.scale(10); + int shift = JBUIScale.scale(2); + int size = JBUIScale.scale(10); g.fillRect(x + shift, y + shift, size, size); } diff --git a/platform/core-ui/src/ui/LayeredIcon.java b/platform/core-ui/src/ui/LayeredIcon.java index 4b25b4c90936..f55535b9c757 100644 --- a/platform/core-ui/src/ui/LayeredIcon.java +++ b/platform/core-ui/src/ui/LayeredIcon.java @@ -1,23 +1,9 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.IconLoader.DarkIconProvider; +import com.intellij.ui.icons.DarkIconProvider; import com.intellij.util.ArrayUtil; import com.intellij.util.IconUtil; import com.intellij.util.ui.JBCachingScalableIcon; @@ -28,8 +14,8 @@ import javax.swing.*; import java.awt.*; import java.util.Arrays; -import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; -import static com.intellij.util.ui.JBUIScale.ScaleType.USR_SCALE; +import static com.intellij.ui.scale.ScaleType.OBJ_SCALE; +import static com.intellij.ui.scale.ScaleType.USR_SCALE; public class LayeredIcon extends JBCachingScalableIcon implements DarkIconProvider, CompositeIcon { private static final Logger LOG = Logger.getInstance("#com.intellij.ui.LayeredIcon"); diff --git a/platform/core-ui/src/ui/OffsetIcon.java b/platform/core-ui/src/ui/OffsetIcon.java index 0ec0e821b448..97c662cc2425 100644 --- a/platform/core-ui/src/ui/OffsetIcon.java +++ b/platform/core-ui/src/ui/OffsetIcon.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui; @@ -11,7 +11,7 @@ import javax.swing.*; import java.awt.*; import java.util.Objects; -import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; +import static com.intellij.ui.scale.ScaleType.OBJ_SCALE; import static java.lang.Math.ceil; public final class OffsetIcon extends JBCachingScalableIcon { diff --git a/platform/core-ui/src/ui/RowIcon.java b/platform/core-ui/src/ui/RowIcon.java index 529e1a8919a9..c8d9abc255e0 100644 --- a/platform/core-ui/src/ui/RowIcon.java +++ b/platform/core-ui/src/ui/RowIcon.java @@ -1,8 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.IconLoader.DarkIconProvider; +import com.intellij.ui.icons.DarkIconProvider; import com.intellij.util.ArrayUtil; import com.intellij.util.IconUtil; import com.intellij.util.containers.ContainerUtil; @@ -14,7 +14,7 @@ import java.awt.*; import java.util.Arrays; import java.util.List; -import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; +import static com.intellij.ui.scale.ScaleType.OBJ_SCALE; import static java.lang.Math.ceil; public class RowIcon extends JBCachingScalableIcon implements DarkIconProvider, CompositeIcon { diff --git a/platform/core-ui/src/util/IconUtil.java b/platform/core-ui/src/util/IconUtil.java index 3952c75f25b6..d2b02fbedc5c 100644 --- a/platform/core-ui/src/util/IconUtil.java +++ b/platform/core-ui/src/util/IconUtil.java @@ -14,9 +14,9 @@ import com.intellij.openapi.vfs.VFileProperty; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.WritingAccessProvider; import com.intellij.ui.*; +import com.intellij.ui.icons.CopyableIcon; +import com.intellij.ui.scale.*; import com.intellij.util.ui.*; -import com.intellij.util.ui.JBUIScale.ScaleContext; -import com.intellij.util.ui.JBUIScale.ScaleContextAware; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,8 +31,8 @@ import java.util.List; import java.util.Objects; import java.util.function.Supplier; -import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; -import static com.intellij.util.ui.JBUIScale.ScaleType.USR_SCALE; +import static com.intellij.ui.scale.ScaleType.OBJ_SCALE; +import static com.intellij.ui.scale.ScaleType.USR_SCALE; /** @@ -512,7 +512,7 @@ public class IconUtil { */ @NotNull public static Icon scaleByFont(@NotNull Icon icon, @Nullable Component ancestor, float fontSize) { - float scale = JBUI.getFontScale(fontSize); + float scale = JBUIScale.getFontScale(fontSize); if (icon instanceof ScaleContextAware) { ScaleContextAware ctxIcon = (ScaleContextAware)icon; // take into account the user scale of the icon @@ -525,10 +525,10 @@ public class IconUtil { /** * Overrides the provided scale in the icon's scale context and in the composited icon's scale contexts (when applicable). * - * @see JBUIScale.UserScaleContext#overrideScale(JBUIScale.Scale) + * @see UserScaleContext#overrideScale(Scale) */ @NotNull - public static Icon overrideScale(@NotNull Icon icon, JBUIScale.Scale scale) { + public static Icon overrideScale(@NotNull Icon icon, Scale scale) { if (icon instanceof CompositeIcon) { CompositeIcon compositeIcon = (CompositeIcon)icon; for (int i = 0; i < compositeIcon.getIconCount(); i++) { @@ -731,7 +731,7 @@ public class IconUtil { } private void update() { - myFont = JBFont.create(JBUI.Fonts.label().deriveFont((float)scaleVal(fontSize, OBJ_SCALE))); // fontSize is in USR_SCALE + myFont = JBFont.create(JBFont.label().deriveFont((float)scaleVal(fontSize, OBJ_SCALE))); // fontSize is in USR_SCALE Component comp = myCompRef.get(); if (comp == null) comp = new Component() {}; myMetrics = comp.getFontMetrics(myFont); @@ -756,7 +756,7 @@ public class IconUtil { public static Icon addText(@NotNull Icon base, @NotNull String text) { LayeredIcon icon = new LayeredIcon(2); icon.setIcon(base, 0); - icon.setIcon(textToIcon(text, new JLabel(), JBUI.scale(6f)), 1, SwingConstants.SOUTH_EAST); + icon.setIcon(textToIcon(text, new JLabel(), JBUIScale.scale(6f)), 1, SwingConstants.SOUTH_EAST); return icon; } diff --git a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java index 0ee2dc39e6cd..62be52900a95 100644 --- a/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java +++ b/platform/diff-impl/src/com/intellij/diff/impl/DiffRequestProcessor.java @@ -55,6 +55,7 @@ import com.intellij.ui.components.JBPanelWithEmptyText; import com.intellij.ui.components.panels.Wrapper; import com.intellij.ui.mac.TouchbarDataKeys; import com.intellij.ui.mac.UpdatableDefaultActionGroup; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -774,7 +775,7 @@ public abstract class DiffRequestProcessor implements Disposable { "You can disable this feature in " + DiffUtil.getSettingsConfigurablePath()); final LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(message)); - Point point = new Point(myContentPanel.getWidth() / 2, next ? myContentPanel.getHeight() - JBUI.scale(40) : JBUI.scale(40)); + Point point = new Point(myContentPanel.getWidth() / 2, next ? myContentPanel.getHeight() - JBUIScale.scale(40) : JBUIScale.scale(40)); if (editor == null) { final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); diff --git a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java index 0c8cb9f36879..a61de4fda217 100644 --- a/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/merge/TextMergeViewer.java @@ -57,9 +57,9 @@ import com.intellij.openapi.vcs.ex.LineStatusTrackerBase; import com.intellij.openapi.vcs.ex.Range; import com.intellij.openapi.vcs.ex.SimpleLineStatusTracker; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUI; import gnu.trove.TIntArrayList; import org.jetbrains.annotations.*; @@ -682,7 +682,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer { if (isDisposed()) return; JComponent component = getEditor().getComponent(); - RelativePoint point = new RelativePoint(component, new Point(component.getWidth() / 2, JBUI.scale(5))); + RelativePoint point = new RelativePoint(component, new Point(component.getWidth() / 2, JBUIScale.scale(5))); String message = DiffBundle.message("merge.all.changes.processed.message.text"); DiffUtil.showSuccessPopup(message, point, this, () -> { @@ -1329,7 +1329,7 @@ public class TextMergeViewer implements MergeTool.MergeViewer { @Override protected int getFramingBorderSize() { - return JBUI.scale(2); + return JBUIScale.scale(2); } @Override diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java index 650352f3b345..d3a42d085a0e 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/DiffSplitter.java @@ -9,8 +9,8 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.ui.Divider; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.registry.Registry; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.GridBag; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.CalledInAwt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,7 +28,7 @@ public class DiffSplitter extends Splitter { @Nullable private AnAction myBottomAction; public DiffSplitter() { - setDividerWidth(JBUI.scale(Registry.intValue("diff.divider.width"))); + setDividerWidth(JBUIScale.scale(Registry.intValue("diff.divider.width"))); } @Override @@ -61,7 +61,7 @@ public class DiffSplitter extends Splitter { add(button1, bag.nextLine()); } if (button1 != null && button2 != null) { - add(Box.createVerticalStrut(JBUI.scale(20)), bag.nextLine()); + add(Box.createVerticalStrut(JBUIScale.scale(20)), bag.nextLine()); } if (button2 != null) { add(button2, bag.nextLine()); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/StatusPanel.java b/platform/diff-impl/src/com/intellij/diff/tools/util/StatusPanel.java index 38633c6ac20b..9e3116eaed0d 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/StatusPanel.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/StatusPanel.java @@ -1,25 +1,8 @@ -/* - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.diff.tools.util; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.ui.AnimatedIcon; -import com.intellij.util.ui.AsyncProcessIcon; -import com.intellij.util.ui.GridBag; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.*; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -36,7 +19,7 @@ public class StatusPanel extends JPanel { myBusySpinner = new AsyncProcessIcon("StatusPanelSpinner"); myBusySpinner.setVisible(false); - GridBag bag = new GridBag().setDefaultInsets(JBUI.insets(0, 2)).setDefaultFill(GridBagConstraints.BOTH); + GridBag bag = new GridBag().setDefaultInsets(JBInsets.create(0, 2)).setDefaultFill(GridBagConstraints.BOTH); add(myBusySpinner, bag.next()); add(myTextLabel, bag.next()); setBorder(JBUI.Borders.empty(0, 2)); diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java b/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java index fb2922df74d4..9c7804f6567c 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/util/ThreeDiffSplitter.java @@ -1,24 +1,10 @@ -/* - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.diff.tools.util; import com.intellij.diff.tools.util.DiffSplitter.Painter; import com.intellij.diff.util.Side; import com.intellij.openapi.util.registry.Registry; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.CalledInAwt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -151,7 +137,7 @@ public class ThreeDiffSplitter extends JPanel { } private static int getDividerWidth() { - return JBUI.scale(Registry.intValue("diff.divider.width")); + return JBUIScale.scale(Registry.intValue("diff.divider.width")); } private class Divider extends JPanel { diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java index 5ac08df41882..a7eb9b0f759f 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java @@ -15,8 +15,8 @@ import com.intellij.openapi.editor.markup.*; import com.intellij.openapi.util.BooleanGetter; import com.intellij.openapi.util.TextRange; import com.intellij.ui.JBColor; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.DocumentUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -133,7 +133,7 @@ public class DiffDrawUtil { g.fill(path); Stroke oldStroke = g.getStroke(); - g.setStroke(new BasicStroke(JBUI.scale(1f))); + g.setStroke(new BasicStroke(JBUIScale.scale(1f))); g.draw(middleCurve); g.setStroke(oldStroke); } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffEmptyHighlighterRenderer.java b/platform/diff-impl/src/com/intellij/diff/util/DiffEmptyHighlighterRenderer.java index 30798dafd993..c1bbed6ae92c 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffEmptyHighlighterRenderer.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffEmptyHighlighterRenderer.java @@ -1,10 +1,10 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.diff.util; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.markup.CustomHighlighterRenderer; import com.intellij.openapi.editor.markup.RangeHighlighter; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -20,6 +20,6 @@ public class DiffEmptyHighlighterRenderer implements CustomHighlighterRenderer { public void paint(@NotNull Editor editor, @NotNull RangeHighlighter highlighter, @NotNull Graphics g) { g.setColor(myDiffType.getColor(editor)); Point point = editor.logicalPositionToXY(editor.offsetToLogicalPosition(highlighter.getStartOffset())); - g.fillRect(point.x - JBUI.scale(1), point.y, JBUI.scale(2), editor.getLineHeight()); + g.fillRect(point.x - JBUIScale.scale(1), point.y, JBUIScale.scale(2), editor.getLineHeight()); } } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java b/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java index faf519190650..7a5abb1ca042 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffLineSeparatorRenderer.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.diff.util; import com.intellij.codeInsight.daemon.impl.HintRenderer; @@ -31,7 +17,7 @@ import com.intellij.openapi.editor.markup.LineSeparatorRenderer; import com.intellij.openapi.util.BooleanGetter; import com.intellij.ui.Gray; import com.intellij.ui.paint.LinePainter2D; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -135,7 +121,7 @@ public class DiffLineSeparatorRenderer implements LineMarkerRendererEx, LineSepa @NotNull EditorImpl editor, @NotNull String description) { EditorColorsScheme scheme = editor.getColorsScheme(); - int rectX = x + JBUI.scale(5); + int rectX = x + JBUIScale.scale(5); int rectWidth = HintRenderer.calcWidthInPixels(editor, description, null); Shape oldClip = g.getClip(); @@ -205,7 +191,7 @@ public class DiffLineSeparatorRenderer implements LineMarkerRendererEx, LineSepa @NotNull private static BufferedImage createImage(@NotNull Graphics2D g, @NotNull Color color, int step, int height) { - Object[] key = new Object[]{color.getRGB(), JBUI.sysScale(g), step, height}; + Object[] key = new Object[]{color.getRGB(), JBUIScale.sysScale(g), step, height}; if (Arrays.equals(ourCachedImageKey, key) && outCachedImage != null) return outCachedImage; int imageWidth = step * 2; diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index 2c22ae8f1f06..15b72492f2d8 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -85,6 +85,7 @@ import com.intellij.ui.JBColor; import com.intellij.ui.ScreenUtil; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ArrayUtil; import com.intellij.util.DocumentUtil; import com.intellij.util.ImageLoader; @@ -112,7 +113,7 @@ public class DiffUtil { public static final Key TEMP_FILE_KEY = Key.create("Diff.TempFile"); @NotNull public static final String DIFF_CONFIG = "diff.xml"; - public static final int TITLE_GAP = JBUI.scale(2); + public static final int TITLE_GAP = JBUIScale.scale(2); public static final List DIFF_FRAME_ICONS = loadDiffFrameImages(); @@ -654,7 +655,7 @@ public class DiffUtil { panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); for (int i = 0; i < components.size(); i++) { - if (i != 0) panel.add(Box.createVerticalStrut(JBUI.scale(gap))); + if (i != 0) panel.add(Box.createVerticalStrut(JBUIScale.scale(gap))); panel.add(components.get(i)); } diff --git a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java index 1d227d31a855..f9da0e83b826 100644 --- a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java +++ b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/DirDiffPanel.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.diff.impl.dir; import com.intellij.diff.DiffContentFactory; @@ -49,6 +35,7 @@ import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBLoadingPanel; import com.intellij.ui.components.JBLoadingPanelListener; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -185,20 +172,20 @@ public class DirDiffPanel implements Disposable, DataProvider { final String name = myModel.getColumnName(i); final TableColumn column = columnModel.getColumn(i); if (DirDiffTableModel.COLUMN_DATE.equals(name)) { - column.setPreferredWidth(JBUI.scale(90)); - column.setMinWidth(JBUI.scale(90)); + column.setPreferredWidth(JBUIScale.scale(90)); + column.setMinWidth(JBUIScale.scale(90)); } else if (DirDiffTableModel.COLUMN_SIZE.equals(name)) { - column.setPreferredWidth(JBUI.scale(120)); - column.setMinWidth(JBUI.scale(90)); + column.setPreferredWidth(JBUIScale.scale(120)); + column.setMinWidth(JBUIScale.scale(90)); } else if (DirDiffTableModel.COLUMN_NAME.equals(name)) { - column.setPreferredWidth(JBUI.scale(800)); - column.setMinWidth(JBUI.scale(120)); + column.setPreferredWidth(JBUIScale.scale(800)); + column.setMinWidth(JBUIScale.scale(120)); } else if (DirDiffTableModel.COLUMN_OPERATION.equals(name)) { - column.setMaxWidth(JBUI.scale(25)); - column.setMinWidth(JBUI.scale(25)); + column.setMaxWidth(JBUIScale.scale(25)); + column.setMinWidth(JBUIScale.scale(25)); } } diff --git a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java index a38ed8756625..8a27a73b39d3 100644 --- a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java +++ b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.ex; import com.intellij.diff.util.DiffDrawUtil; @@ -33,8 +19,8 @@ import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.editor.markup.*; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.TextRange; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; @@ -421,7 +407,7 @@ public abstract class LineStatusMarkerRenderer { } if (borderColor != null) { Stroke oldStroke = g.getStroke(); - g.setStroke(new BasicStroke(JBUI.scale(1))); + g.setStroke(new BasicStroke(JBUIScale.scale(1))); g.setColor(borderColor); UIUtil.drawLine(g, x1, y1, x2 - 1, y1); UIUtil.drawLine(g, x1, y1, x1, y2 - 1); @@ -433,7 +419,7 @@ public abstract class LineStatusMarkerRenderer { private static void paintTriangle(@NotNull Graphics2D g, @NotNull Editor editor, @Nullable Color color, @Nullable Color borderColor, int x1, int x2, int y) { float editorScale = editor instanceof EditorImpl ? ((EditorImpl)editor).getScale() : 1.0f; - int size = (int)JBUI.scale(4 * editorScale); + int size = (int)JBUIScale.scale(4 * editorScale); final int[] xPoints = new int[]{x1, x1, x2}; final int[] yPoints = new int[]{y - size, y + size, y}; @@ -444,7 +430,7 @@ public abstract class LineStatusMarkerRenderer { } if (borderColor != null) { Stroke oldStroke = g.getStroke(); - g.setStroke(new BasicStroke(JBUI.scale(1))); + g.setStroke(new BasicStroke(JBUIScale.scale(1))); g.setColor(borderColor); g.drawPolygon(xPoints, yPoints, xPoints.length); g.setStroke(oldStroke); diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java index 542fc30c34ee..21b11c77e9d7 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java @@ -17,10 +17,10 @@ import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBViewport; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.treeStructure.actions.CollapseAllAction; import com.intellij.ui.treeStructure.actions.ExpandAllAction; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.ThreeStateCheckBox; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.tree.WideSelectionTreeUI; @@ -226,7 +226,7 @@ public class PushLog extends JPanel implements DataProvider { final EditSourceForDialogAction editSourceAction = new EditSourceForDialogAction(myChangesBrowser); editSourceAction.registerCustomShortcutSet(CommonShortcuts.getEditSource(), myChangesBrowser); myChangesBrowser.addToolbarAction(editSourceAction); - myChangesBrowser.setMinimumSize(new Dimension(JBUI.scale(200), myChangesBrowser.getPreferredSize().height)); + myChangesBrowser.setMinimumSize(new Dimension(JBUIScale.scale(200), myChangesBrowser.getPreferredSize().height)); setDefaultEmptyText(); JBSplitter splitter = new JBSplitter(SPLITTER_PROPORTION, 0.7f); @@ -258,7 +258,7 @@ public class PushLog extends JPanel implements DataProvider { setLayout(new BorderLayout()); add(splitter); - myTree.setMinimumSize(new Dimension(JBUI.scale(400), myTree.getPreferredSize().height)); + myTree.setMinimumSize(new Dimension(JBUIScale.scale(400), myTree.getPreferredSize().height)); myTree.setRowHeight(0); myScrollPane.setMinimumSize(new Dimension(myTree.getMinimumSize().width, myScrollPane.getPreferredSize().height)); } diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt index 50c70e6302e9..c24a01300f22 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/NotRoamableUiSettings.kt @@ -3,6 +3,7 @@ package com.intellij.ide.ui import com.intellij.openapi.components.* import com.intellij.openapi.util.Pair +import com.intellij.ui.scale.JBUIScale import com.intellij.util.ui.UIUtil import com.intellij.util.xmlb.Accessor import com.intellij.util.xmlb.SerializationFilter @@ -86,4 +87,4 @@ private class FontFilter : SerializationFilter { } private val systemFontFaceAndSize: Pair - get() = UIUtil.getSystemFontData() ?: Pair.create("Dialog", 12) \ No newline at end of file + get() = JBUIScale.getSystemFontData() \ No newline at end of file diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt index 9d9b537faadd..84400ca9f72f 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt @@ -10,11 +10,13 @@ import com.intellij.openapi.components.Storage import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.util.IconLoader import com.intellij.openapi.util.SystemInfo +import com.intellij.openapi.util.SystemInfoRt import com.intellij.openapi.util.registry.Registry +import com.intellij.ui.JreHiDpiUtil +import com.intellij.ui.scale.JBUIScale import com.intellij.util.ComponentTreeEventDispatcher import com.intellij.util.SystemProperties import com.intellij.util.ui.GraphicsUtil -import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import com.intellij.util.xmlb.annotations.Transient import java.awt.Graphics @@ -380,7 +382,7 @@ class UISettings constructor(private val notRoamableOptions: NotRoamableUiSettin @JvmStatic private fun verbose(msg: String, vararg args: Any) { - if (UIUtil.SCALE_VERBOSE) { + if (JBUIScale.SCALE_VERBOSE) { LOG.info(String.format(msg, *args)) } } @@ -480,7 +482,7 @@ class UISettings constructor(private val notRoamableOptions: NotRoamableUiSettin */ @JvmStatic val defFontScale: Float - get() = if (UIUtil.isJreHiDPIEnabled()) 1f else JBUI.sysScale() + get() = if (JreHiDpiUtil.isJreHiDPIEnabled()) 1f else JBUIScale.sysScale() /** * Returns the default font size scaled by #defFontScale @@ -497,18 +499,16 @@ class UISettings constructor(private val notRoamableOptions: NotRoamableUiSettin if (readScale == null || readScale <= 0) { verbose("Reset font to default") // Reset font to default on switch from IDE-managed HiDPI to JRE-managed HiDPI. Doesn't affect OSX. - if (UIUtil.isJreHiDPIEnabled() && !SystemInfo.isMac) size = UISettingsState.defFontSize + if (JreHiDpiUtil.isJreHiDPIEnabled() && !SystemInfoRt.isMac) size = UISettingsState.defFontSize } else { var oldDefFontScale = defFontScale if (SystemInfo.isLinux) { - val fontData = UIUtil.getSystemFontData() - if (fontData != null) { - // [tav] todo: temp workaround for transitioning IDEA 173 to 181 - // not converting fonts stored with scale equal to the old calculation - oldDefFontScale = fontData.second / 12f - verbose("oldDefFontScale=%.2f", oldDefFontScale) - } + val fontData = JBUIScale.getSystemFontData() + // [tav] todo: temp workaround for transitioning IDEA 173 to 181 + // not converting fonts stored with scale equal to the old calculation + oldDefFontScale = fontData.second / 12f + verbose("oldDefFontScale=%.2f", oldDefFontScale) } if (readScale != defFontScale && readScale != oldDefFontScale) { size = ((readSize / readScale) * defFontScale).roundToInt() diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt index 36729d07e42f..1000f08ffd75 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt @@ -3,11 +3,12 @@ package com.intellij.ide.ui import com.intellij.openapi.components.BaseState import com.intellij.openapi.util.SystemInfo +import com.intellij.ui.scale.JBUIScale import com.intellij.util.PlatformUtils -import com.intellij.util.ui.UIUtil import com.intellij.util.xmlb.annotations.OptionTag import com.intellij.util.xmlb.annotations.Transient import javax.swing.SwingConstants +import kotlin.math.roundToInt class UISettingsState : BaseState() { companion object { @@ -18,10 +19,9 @@ class UISettingsState : BaseState() { */ @JvmStatic val defFontSize: Int - get() = Math.round(UIUtil.DEF_SYSTEM_FONT_SIZE * UISettings.defFontScale) + get() = (JBUIScale.DEF_SYSTEM_FONT_SIZE * UISettings.defFontScale).roundToInt() } - @get:OptionTag("FONT_FACE") @Deprecated("", replaceWith = ReplaceWith("NotRoamableUiOptions.fontFace")) var fontFace by string() diff --git a/platform/editor-ui-ex/src/com/intellij/application/options/EditorFontsConstants.java b/platform/editor-ui-ex/src/com/intellij/application/options/EditorFontsConstants.java index 986a60601159..7b29ce0fc641 100644 --- a/platform/editor-ui-ex/src/com/intellij/application/options/EditorFontsConstants.java +++ b/platform/editor-ui-ex/src/com/intellij/application/options/EditorFontsConstants.java @@ -1,31 +1,23 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; /** * @author Konstantin Bulenkov */ public class EditorFontsConstants { - public static int getMinEditorFontSize() {return JBUI.scale(4);} + public static int getMinEditorFontSize() { + return JBUIScale.scale(4); + } - public static int getMaxEditorFontSize() {return JBUI.scale(40);} + public static int getMaxEditorFontSize() { + return JBUIScale.scale(40); + } - public static int getDefaultEditorFontSize() {return JBUI.scale(12);} + public static int getDefaultEditorFontSize() { + return JBUIScale.scale(12); + } public static float getMinEditorLineSpacing() {return .6f;} diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java index 1047d643ba39..82a45b3adad3 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java @@ -17,10 +17,10 @@ import com.intellij.ui.SideBorder; import com.intellij.ui.TitledSeparator; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtilRt; import com.intellij.util.ui.GridBag; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -128,7 +128,7 @@ public abstract class AbstractExternalSystemConfigurable< .getFillLineConstraints(1) .fillCell() .weighty(1) - .pady(JBUI.scale(30))); + .pady(JBUIScale.scale(30))); ContainerUtil.sort(settings, Comparator.comparing(s2 -> getProjectName(s2.getExternalProjectPath()))); @@ -198,7 +198,7 @@ public abstract class AbstractExternalSystemConfigurable< constraints = ExternalSystemUiUtil.getFillLineConstraints(0); constraints.insets.top = 0; - + panel.add(new TitledSeparator(ExternalSystemBundle.message("settings.title.system.settings")), constraints); mySystemSettingsControl.fillUi(panel, 1); } diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java b/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java index 05f18236d23d..1135f5e4eb03 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java +++ b/platform/lang-api/src/com/intellij/codeInspection/ui/ListTable.java @@ -1,8 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection.ui; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -17,7 +17,7 @@ public class ListTable extends JBTable { super(tableModel); setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS); setRowSelectionAllowed(true); - setRowHeight(getRowHeight() + JBUI.scale(4)); + setRowHeight(getRowHeight() + JBUIScale.scale(4)); setDragEnabled(false); final JTableHeader header = getTableHeader(); header.setReorderingAllowed(false); diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java index 211daa2f9cdb..d2d1a4c96665 100644 --- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java +++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.runners; import com.intellij.execution.*; @@ -25,9 +25,9 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.ColorUtil; import com.intellij.ui.LayeredIcon; import com.intellij.ui.content.Content; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ExceptionUtil; import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -251,7 +251,7 @@ public class ExecutionUtil { @SuppressWarnings("UseJBColor") @Override public void paintIcon(Component c, Graphics g, int x, int y) { - int iSize = JBUI.scale(4); + int iSize = JBUIScale.scale(4); Graphics2D g2d = (Graphics2D)g.create(); try { GraphicsUtil.setupAAPainting(g2d); diff --git a/platform/lang-impl/src/com/intellij/analysis/dialog/VcsScopeItemPresenter.java b/platform/lang-impl/src/com/intellij/analysis/dialog/VcsScopeItemPresenter.java index 995abb34a71b..44fc4ee8396a 100644 --- a/platform/lang-impl/src/com/intellij/analysis/dialog/VcsScopeItemPresenter.java +++ b/platform/lang-impl/src/com/intellij/analysis/dialog/VcsScopeItemPresenter.java @@ -1,6 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.analysis.dialog; import com.intellij.analysis.AnalysisScope; @@ -8,7 +6,7 @@ import com.intellij.analysis.AnalysisScopeBundle; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.SimpleListCellRenderer; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -38,7 +36,7 @@ public class VcsScopeItemPresenter implements ModelScopeItemPresenter { myChangeLists.setRenderer(SimpleListCellRenderer.create((label, value, index) -> { int availableWidth = myChangeLists.getWidth(); // todo, is it correct? if (availableWidth <= 0) { - availableWidth = JBUI.scale(200); + availableWidth = JBUIScale.scale(200); } if (label.getFontMetrics(label.getFont()).stringWidth(value) < availableWidth) { label.setText(value); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java index 004527bdcd4b..e1aea87a45c8 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.codeStyle; import com.intellij.lang.Language; @@ -30,7 +16,7 @@ import com.intellij.ui.components.fields.IntegerField; import com.intellij.ui.components.fields.valueEditors.CommaSeparatedIntegersValueEditor; import com.intellij.ui.components.fields.valueEditors.ValueEditor; import com.intellij.ui.components.labels.ActionLink; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -91,7 +77,7 @@ public class RightMarginForm { }); myRightMarginField.setCanBeEmpty(true); myRightMarginField.setDefaultValue(-1); - myRightMarginField.setMinimumSize(new Dimension(JBUI.scale(120), myRightMarginField.getMinimumSize().height)); + myRightMarginField.setMinimumSize(new Dimension(JBUIScale.scale(120), myRightMarginField.getMinimumSize().height)); myVisualGuidesField = new CommaSeparatedIntegersField(ApplicationBundle.message("settings.code.style.visual.guides"), 0, CodeStyleConstraints.MAX_RIGHT_MARGIN, "Optional"); myVisualGuidesField.getValueEditor().addListener(new ValueEditor.Listener>() { @Override diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesPatternForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesPatternForm.java index 586e8310aca3..b26ff5d47ced 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesPatternForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesPatternForm.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.codeStyle.excludedFiles; import com.intellij.formatting.fileSet.PatternDescriptor; @@ -7,7 +7,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.components.JBTextField; import com.intellij.ui.components.fields.valueEditors.TextFieldValueEditor; import com.intellij.ui.components.fields.valueEditors.ValueEditor; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,7 +20,7 @@ public abstract class ExcludedFilesPatternForm { private JBTextField myPatternField; public ExcludedFilesPatternForm() { - int minWidth = JBUI.scale(400); + int minWidth = JBUIScale.scale(400); int minHeight = myPatternField.getMinimumSize().height; myPatternField.setMinimumSize(new Dimension(minWidth, minHeight)); } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java index 4114903c0d48..16e0412e85ba 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/excludedFiles/ExcludedFilesScopeForm.java @@ -1,8 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.codeStyle.excludedFiles; import com.intellij.ui.components.JBList; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import javax.swing.*; import java.awt.*; @@ -12,7 +12,7 @@ public class ExcludedFilesScopeForm { private JBList myScopesList; public ExcludedFilesScopeForm() { - myTopPanel.setMinimumSize(new Dimension(myTopPanel.getMinimumSize().width, JBUI.scale(100))); + myTopPanel.setMinimumSize(new Dimension(myTopPanel.getMinimumSize().width, JBUIScale.scale(100))); } public JPanel getTopPanel() { diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java index 077c278a344a..28405ef946df 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.colors; import com.intellij.application.options.schemes.AbstractSchemeActions; @@ -20,7 +20,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.components.JBList; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -226,7 +226,7 @@ public abstract class ColorSchemeActions extends AbstractSchemeActions { myLookup = lookup; myNameComponent = new MySimpleColoredComponent(); - myNameComponent.setIconTextGap(JBUI.scale(4)); + myNameComponent.setIconTextGap(JBUIScale.scale(4)); myNameComponent.setIpad(JBUI.insetsLeft(6)); myNameComponent.setMyBorder(null); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index 1d46df3b5080..a3b654e7316b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -47,10 +47,10 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.ui.*; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.JBList; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.CollectConsumer; import com.intellij.util.ExceptionUtil; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.accessibility.AccessibleContextUtil; import com.intellij.util.ui.accessibility.ScreenReader; import com.intellij.util.ui.update.Activatable; @@ -1250,7 +1250,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable, ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(new LookupActionsStep(actions, this, element)); Point p = (itemBounds.intersects(visibleRect) || event == null) ? new Point(itemBounds.x + itemBounds.width, itemBounds.y): - SwingUtilities.convertPoint(event.getComponent(), new Point(0, event.getComponent().getHeight() + JBUI.scale(2)), getComponent()); + SwingUtilities.convertPoint(event.getComponent(), new Point(0, event.getComponent().getHeight() + JBUIScale.scale(2)), getComponent()); listPopup.show(new RelativePoint(getComponent(), p)); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java index 1fbaa1c85f5f..b2a57429940b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/preview/ImagePreviewComponent.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.preview; @@ -24,11 +10,10 @@ import com.intellij.psi.PsiFileSystemItem; import com.intellij.psi.PsiReference; import com.intellij.reference.SoftReference; import com.intellij.ui.JBColor; +import com.intellij.ui.scale.JBUIScale; +import com.intellij.ui.scale.ScaleContext; import com.intellij.util.SVGLoader; import com.intellij.util.ui.ImageUtil; -import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.JBUIScale; -import com.intellij.util.ui.JBUIScale.ScaleContext; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -103,7 +88,7 @@ public class ImagePreviewComponent extends JPanel implements PreviewHintComponen final int i = colorModel.getPixelSize(); return new JLabel(String.format("%dx%d, %dbpp, %s", width, height, i, StringUtil.formatFileSize(imageFileSize))); } - + private static boolean refresh(@NotNull VirtualFile file) throws IOException { Long loadedTimeStamp = file.getUserData(TIMESTAMP_KEY); SoftReference imageRef = file.getUserData(BUFFERED_IMAGE_REF_KEY); @@ -125,7 +110,7 @@ public class ImagePreviewComponent extends JPanel implements PreviewHintComponen @NotNull public static BufferedImage readImageFromBytes(@NotNull byte[] content) throws IOException { try { - Image image = SVGLoader.load(new ByteArrayInputStream(content), JBUI.sysScale()); + Image image = SVGLoader.load(new ByteArrayInputStream(content), JBUIScale.sysScale()); if (image != null) return ImageUtil.toBufferedImage(image); } catch (IOException ignored) {} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java index c65f8de7f397..8f2f95bc4779 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java @@ -27,6 +27,7 @@ import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.labels.DropDownLink; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.containers.TreeTraversal; @@ -346,7 +347,7 @@ public class LiveTemplateSettingsEditor extends JPanel { myContextPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(content, pair.second) .setRequestFocus(true) .setResizable(true).createPopup(); - myContextPopup.show(new RelativePoint(change, new Point(change.getWidth() , -content.getPreferredSize().height - JBUI.scale(4)))); + myContextPopup.show(new RelativePoint(change, new Point(change.getWidth() , -content.getPreferredSize().height - JBUIScale.scale(4)))); myContextPopup.addListener(new JBPopupAdapter() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java index ed2282bd2007..da90d798af18 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java @@ -34,15 +34,17 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.ui.ClickListener; +import com.intellij.ui.ComponentUtil; import com.intellij.util.SequentialModalProgressTask; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.UIUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.tree.TreePath; +import java.awt.*; import java.awt.event.MouseEvent; +import java.util.List; import java.util.*; /** @@ -288,7 +290,7 @@ public abstract class QuickFixAction extends AnAction implements CustomComponent new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { - final ActionToolbar toolbar = UIUtil.getParentOfType(ActionToolbar.class, button); + final ActionToolbar toolbar = ComponentUtil.getParentOfType((Class)ActionToolbar.class, (Component)button); actionPerformed(AnActionEvent.createFromAnAction(QuickFixAction.this, event, place, diff --git a/platform/lang-impl/src/com/intellij/codeInspection/naming/AbstractNamingConventionInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/naming/AbstractNamingConventionInspection.java index 6a6811cfdc9a..6707ff149d08 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/naming/AbstractNamingConventionInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/naming/AbstractNamingConventionInspection.java @@ -13,6 +13,7 @@ import com.intellij.serialization.SerializationException; import com.intellij.ui.CheckBoxList; import com.intellij.ui.CheckBoxListListener; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -185,7 +186,7 @@ public abstract class AbstractNamingConventionInspection)Wrapper.class, (Component)c.getComponent()); JComponent cellWrapper = wrapper == null ? null : (JComponent)wrapper.getParent(); if (cellWrapper == null || !cellWrapper.isShowing()) continue; r = new RelativeRectangle(cellWrapper).getRectangleOn(component); diff --git a/platform/lang-impl/src/com/intellij/find/FindAllAction.java b/platform/lang-impl/src/com/intellij/find/FindAllAction.java index 8f4e56f825cd..ce4e25c6fe7d 100644 --- a/platform/lang-impl/src/com/intellij/find/FindAllAction.java +++ b/platform/lang-impl/src/com/intellij/find/FindAllAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.find; import com.intellij.icons.AllIcons; @@ -10,8 +10,8 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.ui.LayeredIcon; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.IconUtil; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,7 +65,7 @@ public class FindAllAction extends AnAction implements ShortcutProvider, DumbAwa if (session == null || getTemplatePresentation().getIcon() != null) return; Icon base = AllIcons.Actions.Find; - Icon text = IconUtil.textToIcon("ALL", session.getComponent(), JBUI.scale(6F)); + Icon text = IconUtil.textToIcon("ALL", session.getComponent(), JBUIScale.scale(6F)); LayeredIcon icon = new LayeredIcon(2); icon.setIcon(base, 0); diff --git a/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java b/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java index 0fe92bbffb09..333265191daf 100644 --- a/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java +++ b/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java @@ -23,6 +23,7 @@ import com.intellij.ui.SearchTextField; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.components.panels.Wrapper; import com.intellij.ui.mac.TouchbarDataKeys; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.SpeedSearchSupply; import com.intellij.util.EventDispatcher; import com.intellij.util.containers.ContainerUtil; @@ -173,7 +174,7 @@ public class SearchReplaceComponent extends EditorHeaderComponent implements Dat @Override public Dimension getMinimumSize() { Dimension size = super.getMinimumSize(); - size.width += JBUI.scale(16);//looks like hack but we need this extra space in case of lack of width + size.width += JBUIScale.scale(16);//looks like hack but we need this extra space in case of lack of width return size; } }; diff --git a/platform/lang-impl/src/com/intellij/find/SearchTextArea.java b/platform/lang-impl/src/com/intellij/find/SearchTextArea.java index d73909119e68..338dcb494ef4 100644 --- a/platform/lang-impl/src/com/intellij/find/SearchTextArea.java +++ b/platform/lang-impl/src/com/intellij/find/SearchTextArea.java @@ -26,6 +26,7 @@ import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBTextArea; import com.intellij.ui.components.panels.NonOpaquePanel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ArrayUtil; import com.intellij.util.ui.JBDimension; import com.intellij.util.ui.JBInsets; @@ -159,7 +160,7 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList } else { int bottom = (StringUtil.getLineBreakCount(myTextArea.getText()) > 0) ? 2 : UIUtil.isUnderDarcula() ? 2 : 1; int top = myTextArea.getFontMetrics(myTextArea.getFont()).getHeight() <= 16 ? 2 : 1; - if (JBUI.isUsrHiDPI()) { + if (JBUIScale.isUsrHiDPI()) { bottom = 2; top = 2; } @@ -221,7 +222,7 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList add(myScrollPane, "ay top, growx, pushx"); //TODO combine icons/info modes if (myInfoMode) { - add(myInfoLabel, "gapright " + JBUI.scale(4)); + add(myInfoLabel, "gapright " + JBUIScale.scale(4)); } add(myIconsPanel, myHelper.getIconsPanelConstraints()); updateIconsLayout(); @@ -434,24 +435,24 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList private class MacLafHelper extends LafHelper { @Override Border getBorder() { - return new EmptyBorder(3 + Math.max(0, JBUI.scale(16) - UIUtil.getLineHeight(myTextArea)) / 2, 6, 4, 4); + return new EmptyBorder(3 + Math.max(0, JBUIScale.scale(16) - UIUtil.getLineHeight(myTextArea)) / 2, 6, 4, 4); } @Override String getLayoutConstraints() { - return "flowx, ins 0, gapx " + JBUI.scale(4); + return "flowx, ins 0, gapx " + JBUIScale.scale(4); } @Override String getHistoryButtonConstraints() { int extraGap = getExtraGap(); - return "ay top, gaptop " + extraGap + ", gapleft" + (JBUI.isUsrHiDPI() ? 4 : 0); + return "ay top, gaptop " + extraGap + ", gapleft" + (JBUIScale.isUsrHiDPI() ? 4 : 0); } private int getExtraGap() { int height = UIUtil.getLineHeight(myTextArea); Insets insets = myTextArea.getInsets(); - return Math.max(JBUI.isUsrHiDPI() ? 0 : 1, (height + insets.top + insets.bottom - JBUI.scale(16)) / 2); + return Math.max(JBUIScale.isUsrHiDPI() ? 0 : 1, (height + insets.top + insets.bottom - JBUIScale.scale(16)) / 2); } @@ -490,12 +491,12 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList @Override String getLayoutConstraints() { Insets i = SystemInfoRt.isLinux ? JBUI.insets(2) : JBUI.insets(3); - return "flowx, ins " + i.top + " " + i.left + " " + i.bottom + " " + i.right + ", gapx " + JBUI.scale(3); + return "flowx, ins " + i.top + " " + i.left + " " + i.bottom + " " + i.right + ", gapx " + JBUIScale.scale(3); } @Override String getHistoryButtonConstraints() { - return "ay baseline, gaptop " + JBUI.scale(1); + return "ay baseline, gaptop " + JBUIScale.scale(1); } @Override @@ -540,7 +541,7 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList @Override String getLayoutConstraints() { Insets i = JBUI.insets(1, 1, 2, 1); - return "flowx, ins " + i.top + " " + i.left + " " + i.bottom + " " + i.right + ", gapx " + JBUI.scale(3); + return "flowx, ins " + i.top + " " + i.left + " " + i.bottom + " " + i.right + ", gapx " + JBUIScale.scale(3); } @Override @@ -563,7 +564,7 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList } @Override public Insets getBorderInsets(Component c) { - return JBUI.insets(1, 0).asUIResource(); + return JBInsets.create(1, 0).asUIResource(); } @Override @@ -583,7 +584,7 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList g2.setColor(UIManager.getColor("TextField.borderColor")); } - int bw = JBUI.scale(1); + int bw = JBUIScale.scale(1); Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD); border.append(new Rectangle2D.Float(0, 0, width, height), false); border.append(new Rectangle2D.Float(bw, bw, width - bw*2, height - bw*2), false); diff --git a/platform/lang-impl/src/com/intellij/find/actions/CompositeActiveComponent.java b/platform/lang-impl/src/com/intellij/find/actions/CompositeActiveComponent.java index 17a1ef05e220..646c585f2c59 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/CompositeActiveComponent.java +++ b/platform/lang-impl/src/com/intellij/find/actions/CompositeActiveComponent.java @@ -1,22 +1,8 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.find.actions; import com.intellij.ui.ActiveComponent; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -29,7 +15,7 @@ public class CompositeActiveComponent implements ActiveComponent { public CompositeActiveComponent(@NotNull ActiveComponent... components) { myComponents = components; - myComponent = new JPanel(new FlowLayout(FlowLayout.CENTER, JBUI.scale(2), JBUI.scale(2))); + myComponent = new JPanel(new FlowLayout(FlowLayout.CENTER, JBUIScale.scale(2), JBUIScale.scale(2))); myComponent.setBorder(null); myComponent.setOpaque(false); for (ActiveComponent component : components) { diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java index 6999d5df8263..6e6f33f8c6e9 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.find.actions; @@ -25,6 +11,7 @@ import com.intellij.psi.search.SearchScope; import com.intellij.ui.ColorUtil; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.SpeedSearchUtil; import com.intellij.usages.TextChunk; import com.intellij.usages.Usage; @@ -37,7 +24,6 @@ import com.intellij.usages.impl.UsageViewManagerImpl; import com.intellij.usages.rules.UsageInFile; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.EmptyIcon; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.intellij.lang.annotations.MagicConstant; import org.jetbrains.annotations.NotNull; @@ -150,7 +136,7 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer { case USAGE_TEXT_COL: Icon icon = presentation.getIcon(); textChunks.setIcon(icon == null ? EmptyIcon.ICON_16 : icon); - textChunks.append("").appendTextPadding(JBUI.scale(16 + 5)); + textChunks.append("").appendTextPadding(JBUIScale.scale(16 + 5)); for (int i = 1; i < text.length; i++) { TextChunk chunk = text[i]; textChunks.append(chunk.getText(), getAttributes(isSelected, fileBgColor, selectionBg, selectionFg, chunk)); @@ -161,14 +147,14 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer { if (isOriginUsage) { SimpleColoredComponent origin = new SimpleColoredComponent(); - origin.setIconTextGap(JBUI.scale(5)); // for this particular icon it looks better + origin.setIconTextGap(JBUIScale.scale(5)); // for this particular icon it looks better // use attributes of "line number" to show "Current" word SimpleTextAttributes attributes = text.length == 0 ? SimpleTextAttributes.REGULAR_ATTRIBUTES.derive(-1, new Color(0x808080), null, null) : getAttributes(isSelected, fileBgColor, selectionBg, selectionFg, text[0]); origin.append("| Current", attributes); - origin.appendTextPadding(JBUI.scale(45)); + origin.appendTextPadding(JBUIScale.scale(45)); panel.add(origin, BorderLayout.EAST); } break; diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java index 2d329ee90fbc..385a16affe65 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java @@ -57,6 +57,7 @@ import com.intellij.ui.components.JBPanel; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBTextArea; import com.intellij.ui.mac.TouchbarDataKeys; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; import com.intellij.usageView.UsageInfo; import com.intellij.usageView.UsageViewBundle; @@ -254,7 +255,7 @@ public class FindPopupPanel extends JBPanel implements FindUI { if (!myCbPreserveCase.isVisible()) { panelSize.width += myCbPreserveCase.getPreferredSize().width + 8; } - panelSize.width += JBUI.scale(24);//hidden 'loading' icon + panelSize.width += JBUIScale.scale(24);//hidden 'loading' icon panelSize.height *= 2; if (prev != null && prev.height < panelSize.height) prev.height = panelSize.height; Window w = myDialog.getPeer().getWindow(); @@ -458,7 +459,7 @@ public class FindPopupPanel extends JBPanel implements FindUI { Dimension size = super.getPreferredSize(); Insets insets = getInsets(); width += insets.left + insets.right; - size.width = Math.min(JBUI.scale(500), Math.max(JBUI.scale(80), width)); + size.width = Math.min(JBUIScale.scale(500), Math.max(JBUIScale.scale(80), width)); return size; } }; @@ -625,7 +626,7 @@ public class FindPopupPanel extends JBPanel implements FindUI { myResultsPreviewTable.transferFocus(); } }); - applyFont(JBUI.Fonts.label(), myCbCaseSensitive, myCbPreserveCase, myCbWholeWordsOnly, myCbRegularExpressions, + applyFont(JBFont.label(), myCbCaseSensitive, myCbPreserveCase, myCbWholeWordsOnly, myCbRegularExpressions, myResultsPreviewTable); JComponent[] tableAware = {mySearchComponent, myReplaceComponent, myReplaceSelectedButton}; for (JComponent component : tableAware) { @@ -722,7 +723,7 @@ public class FindPopupPanel extends JBPanel implements FindUI { JBSplitter splitter = new JBSplitter(true, .33f); splitter.setSplitterProportionKey(SPLITTER_SERVICE_KEY); - splitter.setDividerWidth(JBUI.scale(2)); + splitter.setDividerWidth(JBUIScale.scale(2)); splitter.getDivider().setBackground(OnePixelDivider.BACKGROUND); JBScrollPane scrollPane = new JBScrollPane(myResultsPreviewTable) { @Override @@ -742,7 +743,7 @@ public class FindPopupPanel extends JBPanel implements FindUI { myNavigationHintLabel.setEnabled(false); myNavigationHintLabel.setFont(JBUI.Fonts.smallFont()); Insets insets = myOKButton.getInsets(); - String btnGapLeft = "gapleft " + Math.max(0, JBUI.scale(12) - insets.left - insets.right); + String btnGapLeft = "gapleft " + Math.max(0, JBUIScale.scale(12) - insets.left - insets.right); bottomPanel.add(myNavigationHintLabel, btnGapLeft); bottomPanel.add(Box.createHorizontalGlue(), "growx, pushx"); @@ -761,7 +762,7 @@ public class FindPopupPanel extends JBPanel implements FindUI { myTitlePanel.add(myTitleLabel); myTitlePanel.add(myLoadingDecorator.getComponent(), "w 24, wmin 24"); myTitlePanel.add(Box.createHorizontalGlue(), "growx, pushx"); - JPanel regexpPanel = new JPanel(new BorderLayout(JBUI.scale(4), 0)); + JPanel regexpPanel = new JPanel(new BorderLayout(JBUIScale.scale(4), 0)); regexpPanel.add(myCbRegularExpressions, BorderLayout.CENTER); regexpPanel.add(RegExHelpPopup.createRegExLink("?", myCbRegularExpressions, LOG), BorderLayout.EAST); int gap = 16; diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupScopeUIImpl.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupScopeUIImpl.java index 2024a8b27b77..89a467cc0f84 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupScopeUIImpl.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupScopeUIImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.find.impl; import com.intellij.find.FindBundle; @@ -21,12 +21,12 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiBundle; import com.intellij.psi.search.SearchScope; import com.intellij.ui.SimpleListCellRenderer; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Functions; import com.intellij.util.ObjectUtils; import com.intellij.util.PlatformUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.EmptyIcon; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -77,7 +77,7 @@ class FindPopupScopeUIImpl implements FindPopupScopeUI { Arrays.sort(names, String.CASE_INSENSITIVE_ORDER); myModuleComboBox = new ComboBox<>(names); myModuleComboBox.setSwingPopup(false); - myModuleComboBox.setMinimumAndPreferredWidth(JBUI.scale(300)); // as ScopeChooser + myModuleComboBox.setMinimumAndPreferredWidth(JBUIScale.scale(300)); // as ScopeChooser myModuleComboBox.setRenderer(SimpleListCellRenderer.create("", Functions.id())); ActionListener restartSearchListener = e -> scheduleResultsUpdate(); diff --git a/platform/lang-impl/src/com/intellij/ide/actions/BigPopupUI.java b/platform/lang-impl/src/com/intellij/ide/actions/BigPopupUI.java index d3fa367e2583..e25f2b102402 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/BigPopupUI.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/BigPopupUI.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.actions; import com.intellij.codeInsight.hint.HintUtil; @@ -14,6 +14,7 @@ import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBTextField; import com.intellij.ui.components.fields.ExtendableTextField; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -100,7 +101,7 @@ public abstract class BigPopupUI extends BorderLayoutPanel implements Disposable @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); - size.height = Integer.max(JBUI.scale(29), size.height); + size.height = Integer.max(JBUIScale.scale(29), size.height); return size; } @@ -218,7 +219,7 @@ public abstract class BigPopupUI extends BorderLayoutPanel implements Disposable hintLabel.setBackground(JBUI.CurrentTheme.BigPopup.advertiserBackground()); hintLabel.setOpaque(true); Dimension size = hintLabel.getPreferredSize(); - size.height = JBUI.scale(17); + size.height = JBUIScale.scale(17); hintLabel.setPreferredSize(size); return hintLabel; } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index f9c52e2f93e6..9772a0473b5f 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -98,6 +98,7 @@ import com.intellij.ui.components.OnOffButton; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.popup.AbstractPopup; import com.intellij.ui.popup.PopupPositionManager; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.Matcher; @@ -226,7 +227,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA private void updateComponents() { myList = new JBList(new SearchListModel()) { - int lastKnownHeight = JBUI.scale(30); + int lastKnownHeight = JBUIScale.scale(30); @Override public Dimension getPreferredSize() { final Dimension size = super.getPreferredSize(); @@ -237,7 +238,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA lastKnownHeight = size.height; } int width = myBalloon != null ? myBalloon.getSize().width : 0; - return new Dimension(Math.max(width, Math.min(size.width - 2, getPopupMaxWidth())), myList.isEmpty() ? JBUI.scale(30) : size.height); + return new Dimension(Math.max(width, Math.min(size.width - 2, getPopupMaxWidth())), myList.isEmpty() ? JBUIScale.scale(30) : size.height); } @Override @@ -2010,7 +2011,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA Dimension size = super.getPreferredSize(); Dimension listSize = myList.getPreferredSize(); if (size.height > listSize.height || myList.getModel().getSize() == 0) { - size.height = Math.max(JBUI.scale(30), listSize.height); + size.height = Math.max(JBUIScale.scale(30), listSize.height); } if (myBalloon != null && size.width < myBalloon.getSize().width) { @@ -2040,7 +2041,9 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA final boolean canClose = balloon == null || balloon.isDisposed() || !getField().getTextEditor().hasFocus() && !mySkipFocusGain; if (canClose) { - PropertiesComponent.getInstance().setValue("search.everywhere.max.popup.width", Math.max(content.getWidth(), JBUI.scale(600)), JBUI.scale(600)); + PropertiesComponent.getInstance().setValue("search.everywhere.max.popup.width", Math.max(content.getWidth(), + JBUIScale.scale(600)), + JBUIScale.scale(600)); } return canClose; }) @@ -2060,7 +2063,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA if (myActionEvent != null && myActionEvent.getInputEvent() instanceof MouseEvent) { final Component component = myActionEvent.getInputEvent().getComponent(); if (component != null) { - final JLabel label = UIUtil.getParentOfType(JLabel.class, component); + final JLabel label = ComponentUtil.getParentOfType((Class)JLabel.class, component); if (label != null) { SwingUtilities.invokeLater(() -> label.setIcon(AllIcons.Actions.Find)); } @@ -2224,7 +2227,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA size.width = parent.getWidth(); } if (myList.getItemsCount() == 0) { - size.height = JBUI.scale(30); + size.height = JBUIScale.scale(30); } Dimension sz = new Dimension(size.width, myList.getPreferredSize().height); if (!SystemInfoRt.isMac) { @@ -2259,7 +2262,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } private static int getPopupMaxWidth() { - return PropertiesComponent.getInstance().getInt("search.everywhere.max.popup.width", JBUI.scale(600)); + return PropertiesComponent.getInstance().getInt("search.everywhere.max.popup.width", JBUIScale.scale(600)); } private void adjustPopup() { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/newclass/CreateWithTemplatesDialogPanel.java b/platform/lang-impl/src/com/intellij/ide/actions/newclass/CreateWithTemplatesDialogPanel.java index 9897166996ce..717c14fea9e5 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/newclass/CreateWithTemplatesDialogPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/newclass/CreateWithTemplatesDialogPanel.java @@ -19,6 +19,7 @@ import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBTextField; import com.intellij.ui.components.fields.ExtendableTextComponent; import com.intellij.ui.components.fields.ExtendableTextField; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.BooleanFunction; import com.intellij.util.Consumer; import com.intellij.util.ui.JBUI; @@ -90,7 +91,7 @@ public class CreateWithTemplatesDialogPanel extends JBPanel implements Disposabl ComponentPopupBuilder popupBuilder = ComponentValidator.createPopupBuilder(new ValidationInfo(error, myNameField), errorHint -> { Insets insets = myNameField.getInsets(); Dimension hintSize = errorHint.getPreferredSize(); - Point point = new Point(0, insets.top - JBUI.scale(6) - hintSize.height); + Point point = new Point(0, insets.top - JBUIScale.scale(6) - hintSize.height); myErrorShowPoint = new RelativePoint(myNameField, point); }).setCancelOnWindowDeactivation(false) .setCancelOnClickOutside(true) @@ -115,8 +116,8 @@ public class CreateWithTemplatesDialogPanel extends JBPanel implements Disposabl Dimension minSize = res.getMinimumSize(); Dimension prefSize = res.getPreferredSize(); - minSize.height = JBUI.scale(28); - prefSize.height = JBUI.scale(28); + minSize.height = JBUIScale.scale(28); + prefSize.height = JBUIScale.scale(28); res.setMinimumSize(minSize); res.setPreferredSize(prefSize); res.setColumns(30); @@ -170,7 +171,7 @@ public class CreateWithTemplatesDialogPanel extends JBPanel implements Disposabl }); Border border = JBUI.Borders.merge( - JBUI.Borders.emptyLeft(JBUI.scale(5)), + JBUI.Borders.emptyLeft(JBUIScale.scale(5)), JBUI.Borders.customLine(JBUI.CurrentTheme.NewClassDialog.bordersColor(), 1, 0, 0, 0), true ); @@ -217,7 +218,7 @@ public class CreateWithTemplatesDialogPanel extends JBPanel implements Disposabl boolean isSelected, boolean cellHasFocus) { JComponent delegate = (JComponent) delegateRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - delegate.setBorder(JBUI.Borders.empty(JBUI.scale(3), JBUI.scale(1))); + delegate.setBorder(JBUI.Borders.empty(JBUIScale.scale(3), JBUIScale.scale(1))); return delegate; } }; diff --git a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/RunConfigurationsSEContributor.java b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/RunConfigurationsSEContributor.java index f90d4af1a49f..6396e31749df 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/RunConfigurationsSEContributor.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/RunConfigurationsSEContributor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.actions.searcheverywhere; import com.intellij.execution.Executor; @@ -19,6 +19,7 @@ import com.intellij.psi.codeStyle.MinusculeMatcher; import com.intellij.psi.codeStyle.NameUtil; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.Processor; import com.intellij.util.ui.JBUI; @@ -177,7 +178,7 @@ public class RunConfigurationsSEContributor implements SearchEverywhereContribut super(new BorderLayout()); add(runConfigInfo, BorderLayout.CENTER); add(executorInfo, BorderLayout.EAST); - setBorder(JBUI.Borders.empty(1, UIUtil.isUnderWin10LookAndFeel() ? 0 : JBUI.scale(UIUtil.getListCellHPadding()))); + setBorder(JBUI.Borders.empty(1, UIUtil.isUnderWin10LookAndFeel() ? 0 : JBUIScale.scale(UIUtil.getListCellHPadding()))); } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java index fd3d8092a917..baa7811ec3bd 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/SearchEverywhereUI.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.actions.searcheverywhere; import com.google.common.collect.Lists; @@ -46,6 +46,7 @@ import com.intellij.ui.components.JBList; import com.intellij.ui.components.fields.ExtendableTextComponent; import com.intellij.ui.components.fields.ExtendableTextField; import com.intellij.ui.popup.PopupUpdateProcessor; +import com.intellij.ui.scale.JBUIScale; import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; import com.intellij.usages.impl.UsageViewManagerImpl; @@ -58,6 +59,7 @@ import com.intellij.util.diff.FilesTooBigForDiffException; import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.text.MatcherHolder; import com.intellij.util.ui.EmptyIcon; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -398,7 +400,7 @@ public class SearchEverywhereUI extends BigPopupUI implements DataProvider, Quic @Override public int getIconGap() { - return JBUI.scale(10); + return JBUIScale.scale(10); } }; } @@ -496,7 +498,7 @@ public class SearchEverywhereUI extends BigPopupUI implements DataProvider, Quic @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); - size.height = JBUI.scale(29); + size.height = JBUIScale.scale(29); return size; } @@ -998,7 +1000,7 @@ public class SearchEverywhereUI extends BigPopupUI implements DataProvider, Quic } setFont(UIUtil.getLabelFont().deriveFont(UIUtil.getFontSize(UIUtil.FontSize.SMALL))); append("... more", SMALL_LABEL_ATTRS); - setIpad(JBUI.insets(1, 7)); + setIpad(JBInsets.create(1, 7)); setMyBorder(null); } }; diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java index 4006fc1b08c0..635a5bd80476 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.bookmarks; @@ -67,7 +53,7 @@ import java.lang.ref.Reference; import java.lang.ref.WeakReference; import static com.intellij.ide.ui.UISettings.setupAntialiasing; -import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; +import static com.intellij.ui.scale.ScaleType.OBJ_SCALE; public class Bookmark implements Navigatable, Comparable { static final Icon DEFAULT_ICON = new MyCheckedIcon(); diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java index 3590bcab5e45..a284dbc57175 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/AllFileTemplatesConfigurable.java @@ -28,6 +28,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.TabbedPaneWrapper; import com.intellij.ui.border.CustomLineBorder; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ArrayUtil; import com.intellij.util.PlatformIcons; import com.intellij.util.containers.ContainerUtil; @@ -331,7 +332,7 @@ public final class AllFileTemplatesConfigurable implements SearchableConfigurabl JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.add(myTabbedPane.getComponent(), BorderLayout.NORTH); Splitter splitter = new Splitter(false, 0.3f); - splitter.setDividerWidth(JBUI.scale(10)); + splitter.setDividerWidth(JBUIScale.scale(10)); splitter.setFirstComponent(leftPanelWrapper); splitter.setSecondComponent(myEditorComponent); centerPanel.add(splitter, BorderLayout.CENTER); diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java index a93cc618d808..ef0304e5bb5a 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateConfigurable.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.fileTemplates.impl; import com.google.common.annotations.VisibleForTesting; @@ -42,6 +42,7 @@ import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.SeparatorFactory; import com.intellij.ui.components.panels.HorizontalLayout; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.xml.util.XmlStringUtil; @@ -108,10 +109,10 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc JBUI.insetsRight(2), 0, 0)); myTopPanel.add(myNameField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.HORIZONTAL, JBUI.insets(3, 2), 0, 0)); + GridBagConstraints.HORIZONTAL, JBInsets.create(3, 2), 0, 0)); myTopPanel.add(new JLabel(IdeBundle.message("label.extension")), new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - JBUI.insets(0, 2), 0, 0)); + JBInsets.create(0, 2), 0, 0)); myTopPanel.add(myExtensionField, new GridBagConstraints(3, 0, 1, 1, .3, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, JBUI.insetsLeft(2), 0, 0)); diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarActions.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarActions.java index 0944a2a9f2db..659a781a94b7 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarActions.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarActions.java @@ -4,10 +4,10 @@ package com.intellij.ide.navigationToolbar; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.DumbAware; +import com.intellij.ui.ComponentUtil; import org.jetbrains.annotations.NotNull; import static com.intellij.openapi.actionSystem.PlatformDataKeys.CONTEXT_COMPONENT; -import static com.intellij.util.ui.UIUtil.getParentOfType; /** * @author Sergey.Malenkov @@ -19,13 +19,13 @@ public abstract class NavBarActions extends AnAction implements DumbAware { @Override public final void update(@NotNull AnActionEvent event) { - NavBarPanel panel = getParentOfType(NavBarPanel.class, event.getData(CONTEXT_COMPONENT)); + NavBarPanel panel = ComponentUtil.getParentOfType((Class)NavBarPanel.class, event.getData(CONTEXT_COMPONENT)); event.getPresentation().setEnabled(panel != null); } @Override public final void actionPerformed(@NotNull AnActionEvent event) { - NavBarPanel panel = getParentOfType(NavBarPanel.class, event.getData(CONTEXT_COMPONENT)); + NavBarPanel panel = ComponentUtil.getParentOfType((Class)NavBarPanel.class, event.getData(CONTEXT_COMPONENT)); if (panel != null) actionPerformed(panel); } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java index c2fb299b8281..2adbc92f426c 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java @@ -305,8 +305,9 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis item.update(); } if (UISettings.getInstance().getShowNavigationBar()) { - NavBarRootPaneExtension.NavBarWrapperPanel wrapperPanel = UIUtil.getParentOfType( - NavBarRootPaneExtension.NavBarWrapperPanel.class, this); + NavBarRootPaneExtension.NavBarWrapperPanel wrapperPanel = ComponentUtil + .getParentOfType((Class)NavBarRootPaneExtension.NavBarWrapperPanel.class, + (Component)this); if (wrapperPanel != null) { wrapperPanel.revalidate(); diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarUpdateQueue.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarUpdateQueue.java index 6c73490f6625..9bfbb8532cbb 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarUpdateQueue.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarUpdateQueue.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.navigationToolbar; import com.intellij.ide.DataManager; @@ -24,11 +10,11 @@ import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.IdeFrame; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.LightweightHint; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.Alarm; import com.intellij.util.Consumer; -import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; import org.jetbrains.annotations.Nullable; @@ -126,7 +112,7 @@ public class NavBarUpdateQueue extends MergingUpdateQueue { Component focus = null; if (!wnd.isActive()) { - IdeFrame frame = UIUtil.getParentOfType(IdeFrame.class, myPanel); + IdeFrame frame = ComponentUtil.getParentOfType((Class)IdeFrame.class, (Component)myPanel); if (frame != null) { focus = IdeFocusManager.getInstance(project).getLastFocusedFor(frame); } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java index feb6835fa7e5..76bcd8fabc32 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.navigationToolbar; @@ -22,7 +8,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; -import com.intellij.util.ui.UIUtil; +import com.intellij.ui.ComponentUtil; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -53,7 +39,7 @@ public class ShowNavBarAction extends AnAction implements DumbAware, PopupAction private static boolean isInsideNavBar(Component c) { return c == null || c instanceof NavBarPanel - || UIUtil.getParentOfType(NavBarListWrapper.class, c) != null; + || ComponentUtil.getParentOfType((Class)NavBarListWrapper.class, c) != null; } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/AbstractNavBarUI.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/AbstractNavBarUI.java index 5c7a37a679f4..90e40cfa848e 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/AbstractNavBarUI.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/AbstractNavBarUI.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.navigationToolbar.ui; import com.intellij.icons.AllIcons; @@ -8,6 +8,7 @@ import com.intellij.ide.ui.UISettings; import com.intellij.ui.ColorUtil; import com.intellij.ui.Gray; import com.intellij.ui.JBColor; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -38,7 +39,7 @@ public abstract class AbstractNavBarUI implements NavBarUI { @Override public Insets getElementIpad(boolean isPopupElement) { - return isPopupElement ? JBUI.insets(1, 2) : JBUI.emptyInsets(); + return isPopupElement ? JBInsets.create(1, 2) : JBUI.emptyInsets(); } @Override @@ -173,7 +174,7 @@ public abstract class AbstractNavBarUI implements NavBarUI { if (!item.isLastElement()) { if (!selected && (!navbar.isFocused() | !item.isNextSelected())) { Icon icon = AllIcons.Ide.NavBarSeparator; - icon.paintIcon(item, g2, w - icon.getIconWidth() - JBUI.scale(1), h2 - icon.getIconHeight() / 2); + icon.paintIcon(item, g2, w - icon.getIconWidth() - JBUIScale.scale(1), h2 - icon.getIconHeight() / 2); } } @@ -182,11 +183,11 @@ public abstract class AbstractNavBarUI implements NavBarUI { } private static int getDecorationOffset() { - return JBUI.scale(8); - } + return JBUIScale.scale(8); + } private static int getFirstElementLeftOffset() { - return JBUI.scale(6); + return JBUIScale.scale(6); } @Override @@ -203,7 +204,7 @@ public abstract class AbstractNavBarUI implements NavBarUI { public Insets getWrapperPanelInsets(Insets insets) { final JBInsets result = JBUI.insets(insets); if (shouldPaintWrapperPanel()) { - result.top += JBUI.scale(1); + result.top += JBUIScale.scale(1); } return result; } @@ -227,6 +228,6 @@ public abstract class AbstractNavBarUI implements NavBarUI { @Override public int getPopupOffset(@NotNull NavBarItem item) { - return item.isFirstElement() ? 0 : JBUI.scale(5); + return item.isFirstElement() ? 0 : JBUIScale.scale(5); } } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/FileNestingInProjectViewDialog.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/FileNestingInProjectViewDialog.java index 4783b0d2d155..15970f6f93cd 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/FileNestingInProjectViewDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/FileNestingInProjectViewDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.projectView.impl; import com.intellij.ide.IdeBundle; @@ -9,6 +9,7 @@ import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.ToolbarDecorator; import com.intellij.ui.components.JBCheckBox; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.TableView; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; @@ -20,8 +21,8 @@ import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.*; import java.util.List; +import java.util.*; public class FileNestingInProjectViewDialog extends DialogWrapper { private static final Comparator RULE_COMPARATOR = @@ -64,7 +65,7 @@ public class FileNestingInProjectViewDialog extends DialogWrapper { @Override protected JComponent createCenterPanel() { - final JPanel mainPanel = new JPanel(new BorderLayout(0, JBUI.scale(16))); + final JPanel mainPanel = new JPanel(new BorderLayout(0, JBUIScale.scale(16))); mainPanel.setBorder(JBUI.Borders.emptyTop(8)); // Resulting indent will be 16 = 8 (default) + 8 (set here) mainPanel.add(myUseNestingRulesCheckBox, BorderLayout.NORTH); mainPanel.add(myRulesPanel, BorderLayout.CENTER); @@ -97,7 +98,7 @@ public class FileNestingInProjectViewDialog extends DialogWrapper { new ColumnInfo("Parent file suffix") { @Override public int getWidth(JTable table) { - return JBUI.scale(125); + return JBUIScale.scale(125); } @Override diff --git a/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java b/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java index 32ca82da74fa..a9fd84f57cea 100644 --- a/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java @@ -12,9 +12,9 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.psi.search.TodoAttributesUtil; import com.intellij.psi.search.TodoPattern; import com.intellij.ui.*; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; import com.intellij.util.ui.FormBuilder; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.table.IconTableCellRenderer; import org.jetbrains.annotations.NotNull; @@ -33,7 +33,7 @@ import java.util.List; * @author Vladimir Kondratyev */ public class TodoConfigurable implements SearchableConfigurable, Configurable.NoScroll { - private static final int HEADER_GAP = JBUI.scale(20); + private static final int HEADER_GAP = JBUIScale.scale(20); /* * UI resources */ diff --git a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java index e4cc76646e6a..101f78228efa 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/FileStructurePopup.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.util; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; @@ -53,6 +53,7 @@ import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.popup.AbstractPopup; import com.intellij.ui.popup.HintUpdateSupply; import com.intellij.ui.popup.PopupUpdateProcessor; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.ElementFilter; import com.intellij.ui.tree.AsyncTreeModel; import com.intellij.ui.tree.StructureTreeModel; @@ -489,7 +490,7 @@ public class FileStructurePopup implements Disposable, TreeActionsOwner { JPanel panel = new JPanel(new BorderLayout()); panel.setPreferredSize(JBUI.size(540, 500)); JPanel chkPanel = new JPanel(new GridLayout(0, checkBoxCount > 0 && checkBoxCount % 4 == 0 ? checkBoxCount / 2 : 3, - JBUI.scale(UIUtil.DEFAULT_HGAP), 0)); + JBUIScale.scale(UIUtil.DEFAULT_HGAP), 0)); chkPanel.setOpaque(false); Shortcut[] F4 = ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet().getShortcuts(); diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java index e6faa8a30a6a..8eda654d0328 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java @@ -57,6 +57,7 @@ import com.intellij.ui.popup.AbstractPopup; import com.intellij.ui.popup.PopupOwner; import com.intellij.ui.popup.PopupPositionManager; import com.intellij.ui.popup.PopupUpdateProcessor; +import com.intellij.ui.scale.JBUIScale; import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; import com.intellij.usages.impl.UsageViewManagerImpl; @@ -447,7 +448,7 @@ public abstract class ChooseByNameBase implements ChooseByNameViewModel { myTextFieldPanel.add(myTextField); Font editorFont = EditorUtil.getEditorFont(); myTextField.setFont(editorFont); - myTextField.putClientProperty("caretWidth", JBUI.scale(EditorUtil.getDefaultCaretWidth())); + myTextField.putClientProperty("caretWidth", JBUIScale.scale(EditorUtil.getDefaultCaretWidth())); if (checkBoxName != null) { if (myCheckBoxShortcut != null) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java index a4d3e6eb247a..4e9568402351 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java @@ -19,11 +19,11 @@ import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.TitledSeparator; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.BitUtil; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBEmptyBorder; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.intellij.lang.annotations.MagicConstant; import org.jetbrains.annotations.NotNull; @@ -88,7 +88,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo addActionListener(this::handleScopeChooserAction); ComboBox combo = getComboBox(); - combo.setMinimumAndPreferredWidth(JBUI.scale(300)); + combo.setMinimumAndPreferredWidth(JBUIScale.scale(300)); combo.setRenderer(createDefaultRenderer()); combo.setSwingPopup(false); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java index 88309b7228fe..26455f5ce008 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java @@ -30,6 +30,7 @@ import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.border.CustomLineBorder; import com.intellij.ui.roots.ToolbarPanel; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -169,7 +170,7 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor { JPanel contentPanel = new JPanel(new GridBagLayout()); final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar("ProjectStructureContentEntries", myRootTreeEditor.getEditingActionsGroup(), true); contentPanel.add(new JLabel("Mark as:"), - new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, JBUI.insets(0, 10), 0, 0)); + new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, 0, JBInsets.create(0, 10), 0, 0)); contentPanel.add(actionToolbar.getComponent(), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0)); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryTreeEditor.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryTreeEditor.java index 92f0bf0d852e..acaadf5e89c9 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryTreeEditor.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentEntryTreeEditor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.roots.ui.configuration; @@ -36,6 +36,7 @@ import com.intellij.ui.JBColor; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.TreeSpeedSearch; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.ui.GridBag; import com.intellij.util.ui.JBUI; @@ -84,7 +85,7 @@ public class ContentEntryTreeEditor { JPanel excludePatternsPanel = new JPanel(new GridBagLayout()); excludePatternsPanel.setBorder(JBUI.Borders.empty(5)); - GridBag gridBag = new GridBag().setDefaultWeightX(1, 1.0).setDefaultPaddingX(JBUI.scale(5)); + GridBag gridBag = new GridBag().setDefaultWeightX(1, 1.0).setDefaultPaddingX(JBUIScale.scale(5)); excludePatternsPanel.add(new JLabel(ProjectBundle.message("module.paths.exclude.patterns")), gridBag.nextLine().next()); myExcludePatternsField = new JTextField(); myExcludePatternsField.getDocument().addDocumentListener(new DocumentAdapter() { diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index 01a296dc389b..44f2d33d76ab 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -774,23 +774,23 @@ public class SingleInspectionProfilePanel extends JPanel { severityPanel.add(new JLabel(InspectionsBundle.message("inspection.severity")), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, - JBUI.insets(10, 0), 0, 0)); + JBInsets.create(10, 0), 0, 0)); final JComponent severityLevelChooserComponent = severityLevelChooser.createCustomComponent( severityLevelChooser.getTemplatePresentation(), ActionPlaces.UNKNOWN); severityPanel.add(severityLevelChooserComponent, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, - JBUI.insets(10, 0), 0, 0)); + JBInsets.create(10, 0), 0, 0)); final JComponent scopesChooserComponent = scopesChooser.createCustomComponent( scopesChooser.getTemplatePresentation(), ActionPlaces.UNKNOWN); severityPanel.add(scopesChooserComponent, new GridBagConstraints(2, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, - JBUI.insets(10, 0), 0, 0)); + JBInsets.create(10, 0), 0, 0)); final JLabel label = new JLabel("", SwingConstants.RIGHT); severityPanel.add(label, new GridBagConstraints(3, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH, - JBUI.insets(2, 0), 0, 0)); + JBInsets.create(2, 0), 0, 0)); severityPanelWeightY = 0.0; if (singleNode != null) { setConfigPanel(configPanelAnchor, myProfile.getToolDefaultState(singleNode.getDefaultDescriptor().getKey().toString(), diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java index a487d2a1d8ba..30ef498d09a3 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java @@ -20,13 +20,13 @@ import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel; import com.intellij.profile.codeInspection.ui.table.ScopesAndSeveritiesTable; import com.intellij.profile.codeInspection.ui.table.ThreeStateCheckBoxRenderer; import com.intellij.ui.DoubleClickListener; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.treeStructure.treetable.TreeTable; import com.intellij.ui.treeStructure.treetable.TreeTableModel; import com.intellij.ui.treeStructure.treetable.TreeTableTree; import com.intellij.util.Alarm; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.TextTransferable; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.table.IconTableCellRenderer; @@ -87,10 +87,10 @@ public class InspectionsConfigTreeTable extends TreeTable { return value; } }); - severitiesColumn.setMaxWidth(JBUI.scale(20)); + severitiesColumn.setMaxWidth(JBUIScale.scale(20)); TableColumn isEnabledColumn = getColumnModel().getColumn(IS_ENABLED_COLUMN); - isEnabledColumn.setMaxWidth(JBUI.scale(22 + getAdditionalPadding())); + isEnabledColumn.setMaxWidth(JBUIScale.scale(22 + getAdditionalPadding())); ThreeStateCheckBoxRenderer boxRenderer = new ThreeStateCheckBoxRenderer(); boxRenderer.setOpaque(true); isEnabledColumn.setCellRenderer(boxRenderer); diff --git a/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsDialog.java b/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsDialog.java index e87f6c718886..a447d5d9e4be 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.inline; import com.intellij.openapi.progress.ProgressManager; @@ -11,7 +11,7 @@ import com.intellij.psi.search.PsiSearchHelper; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.refactoring.ui.RefactoringDialog; import com.intellij.refactoring.util.RadioUpDownListener; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -57,7 +57,7 @@ public abstract class InlineOptionsDialog extends RefactoringDialog implements I @Override protected JComponent createCenterPanel() { JPanel optionsPanel = new JPanel(); - optionsPanel.setBorder(new EmptyBorder(JBUI.scale(10), 0, 0, 0)); + optionsPanel.setBorder(new EmptyBorder(JBUIScale.scale(10), 0, 0, 0)); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); myRbInlineAll = new JRadioButton(); @@ -73,11 +73,11 @@ public abstract class InlineOptionsDialog extends RefactoringDialog implements I myKeepTheDeclaration.setText(keepDeclarationText); optionsPanel.add(myKeepTheDeclaration); } - + optionsPanel.add(myRbInlineThisOnly); ButtonGroup bg = new ButtonGroup(); - final JRadioButton[] buttons = myKeepTheDeclaration != null - ? new JRadioButton[] {myRbInlineAll, myKeepTheDeclaration, myRbInlineThisOnly} + final JRadioButton[] buttons = myKeepTheDeclaration != null + ? new JRadioButton[] {myRbInlineAll, myKeepTheDeclaration, myRbInlineThisOnly} : new JRadioButton[] {myRbInlineAll, myRbInlineThisOnly}; for (JRadioButton button : buttons) { bg.add(button); @@ -90,12 +90,12 @@ public abstract class InlineOptionsDialog extends RefactoringDialog implements I if (canInlineThisOnly()) { myRbInlineAll.setSelected(false); myRbInlineAll.setEnabled(false); - + if (myKeepTheDeclaration != null) { myKeepTheDeclaration.setSelected(false); myKeepTheDeclaration.setEnabled(false); } - + myRbInlineThisOnly.setSelected(true); } else { if (writable) { @@ -127,7 +127,7 @@ public abstract class InlineOptionsDialog extends RefactoringDialog implements I for (JRadioButton button : buttons) { button.addActionListener(previewListener); } - + return optionsPanel; } diff --git a/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsWithSearchSettingsDialog.java b/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsWithSearchSettingsDialog.java index 025678e03437..2008e76afecd 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsWithSearchSettingsDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/inline/InlineOptionsWithSearchSettingsDialog.java @@ -1,26 +1,11 @@ -/* - * Copyright 2000-2009 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.inline; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.refactoring.RefactoringBundle; -import com.intellij.util.ui.JBInsets; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -38,7 +23,7 @@ public abstract class InlineOptionsWithSearchSettingsDialog extends InlineOption protected abstract boolean isSearchInCommentsAndStrings(); protected abstract void saveSearchInCommentsAndStrings(boolean searchInComments); - + protected abstract boolean isSearchForTextOccurrences(); protected abstract void saveSearchInTextOccurrences(boolean searchInTextOccurrences); @@ -74,7 +59,7 @@ public abstract class InlineOptionsWithSearchSettingsDialog extends InlineOption gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; gbc.gridwidth = 2; - gbc.insets.bottom = JBUI.scale(10); + gbc.insets.bottom = JBUIScale.scale(10); panel.add(super.createCenterPanel(), gbc); myCbSearchInComments = new JCheckBox(RefactoringBundle.message("search.in.comments.and.strings"), isSearchInCommentsAndStrings()); diff --git a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteDialog.java b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteDialog.java index 0f08421413e1..786722b42378 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.refactoring.safeDelete; import com.intellij.ide.IdeBundle; @@ -13,6 +13,7 @@ import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.RefactoringSettings; import com.intellij.refactoring.util.TextOccurrencesUtil; import com.intellij.ui.StateRestoringCheckBox; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.Nullable; @@ -72,7 +73,7 @@ public class SafeDeleteDialog extends DialogWrapper { final String promptKey = isDelete() ? "prompt.delete.elements" : "search.for.usages.and.delete.elements"; final String warningMessage = DeleteUtil.generateWarningMessage(IdeBundle.message(promptKey), myElements); - gbc.insets = JBUI.insets(4, 8); + gbc.insets = JBInsets.create(4, 8); gbc.weighty = 1; gbc.weightx = 1; gbc.gridx = 0; diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/ColorButtonBase.java b/platform/lang-impl/src/com/intellij/ui/tabs/ColorButtonBase.java index 10df550064aa..48ffef842b76 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/ColorButtonBase.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/ColorButtonBase.java @@ -1,10 +1,10 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.tabs; import com.intellij.notification.impl.ui.StickyButton; import com.intellij.notification.impl.ui.StickyButtonUI; import com.intellij.ui.JBColor; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -94,7 +94,7 @@ public abstract class ColorButtonBase extends StickyButton { @Override protected int getArcSize() { - return JBUI.scale(15); + return JBUIScale.scale(15); } } } diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java index 2a9509043f6e..0b0ac6d9cd5c 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.webcore.packaging; import com.intellij.icons.AllIcons; @@ -15,10 +15,10 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.*; import com.intellij.ui.components.JBList; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.CatchingConsumer; import com.intellij.util.Function; import com.intellij.util.ObjectUtils; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.PlatformColors; import com.intellij.util.ui.SwingHelper; import com.intellij.util.ui.UIUtil; @@ -116,10 +116,10 @@ public class ManagePackagesDialog extends DialogWrapper { .disableRemoveAction() .addExtraAction(reloadButton) .createPanel(); - packagesPanel.setPreferredSize(new Dimension(JBUI.scale(400), -1)); - packagesPanel.setMinimumSize(new Dimension(JBUI.scale(100), -1)); + packagesPanel.setPreferredSize(new Dimension(JBUIScale.scale(400), -1)); + packagesPanel.setMinimumSize(new Dimension(JBUIScale.scale(100), -1)); myPackages.setFixedCellWidth(0); - myPackages.setFixedCellHeight(JBUI.scale(22)); + myPackages.setFixedCellHeight(JBUIScale.scale(22)); myPackages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mySplitPane.setLeftComponent(packagesPanel); @@ -162,7 +162,7 @@ public class ManagePackagesDialog extends DialogWrapper { else { myInstallToUser.setVisible(false); } - myMainPanel.setPreferredSize(new Dimension(JBUI.scale(900), JBUI.scale(700))); + myMainPanel.setPreferredSize(new Dimension(JBUIScale.scale(900), JBUIScale.scale(700))); } public void selectPackage(@NotNull InstalledPackage pkg) { diff --git a/platform/platform-api/src/com/intellij/ide/HelpTooltip.java b/platform/platform-api/src/com/intellij/ide/HelpTooltip.java index a943a4763ee8..839b4d5f08d1 100644 --- a/platform/platform-api/src/com/intellij/ide/HelpTooltip.java +++ b/platform/platform-api/src/com/intellij/ide/HelpTooltip.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide; import com.intellij.openapi.ui.popup.ComponentPopupBuilder; @@ -24,6 +10,7 @@ import com.intellij.ui.JBColor; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.panels.VerticalLayout; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.ui.*; import org.jetbrains.annotations.ApiStatus; @@ -140,21 +127,21 @@ public class HelpTooltip { RIGHT { @Override public Point getPointFor(JComponent owner, Dimension popupSize) { Dimension size = owner.getSize(); - return new Point(size.width + JBUI.scale(5) - X_OFFSET.get(), JBUI.scale(1) + Y_OFFSET.get()); + return new Point(size.width + JBUIScale.scale(5) - X_OFFSET.get(), JBUIScale.scale(1) + Y_OFFSET.get()); } }, BOTTOM { @Override public Point getPointFor(JComponent owner, Dimension popupSize) { Dimension size = owner.getSize(); - return new Point(JBUI.scale(1) + X_OFFSET.get(), JBUI.scale(5) + size.height - Y_OFFSET.get()); + return new Point(JBUIScale.scale(1) + X_OFFSET.get(), JBUIScale.scale(5) + size.height - Y_OFFSET.get()); } }, HELP_BUTTON { @Override public Point getPointFor(JComponent owner, Dimension popupSize) { Insets i = owner.getInsets(); - return new Point(X_OFFSET.get() - JBUI.scale(40), i.top + Y_OFFSET.get() - JBUI.scale(6) - popupSize.height); + return new Point(X_OFFSET.get() - JBUIScale.scale(40), i.top + Y_OFFSET.get() - JBUIScale.scale(6) - popupSize.height); } }; diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java index 7d32b3b6ca7c..0728f881ff20 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/CheckboxAction.java @@ -1,15 +1,16 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.actionSystem.ex; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.*; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.components.JBCheckBox; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; @@ -76,7 +77,8 @@ public abstract class CheckboxAction extends ToggleAction implements CustomCompo @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox)e.getSource(); - ActionToolbar actionToolbar = UIUtil.getParentOfType(ActionToolbar.class, checkBox); + ActionToolbar actionToolbar = + ComponentUtil.getParentOfType((Class)ActionToolbar.class, (Component)checkBox); DataContext dataContext = actionToolbar != null ? actionToolbar.getToolbarDataContext() : DataManager.getInstance().getDataContext(checkBox); InputEvent inputEvent = new KeyEvent(checkBox, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, KeyEvent.VK_SPACE, ' '); diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java index bdaed119c782..f4583fd5259d 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.actionSystem.ex; import com.intellij.icons.AllIcons; @@ -20,6 +20,7 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; import com.intellij.ui.UserActivityProviderComponent; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.*; import com.intellij.util.ui.accessibility.ScreenReader; import org.jetbrains.annotations.NotNull; @@ -97,7 +98,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent JPanel panel = new JPanel(new GridBagLayout()); ComboBoxButton button = createComboBoxButton(presentation); GridBagConstraints constraints = new GridBagConstraints( - 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.insets(0, 3), 0, 0); + 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBInsets.create(0, 3), 0, 0); panel.add(button, constraints); return panel; } @@ -313,10 +314,10 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent Dimension prefSize = super.getPreferredSize(); int width = prefSize.width + (myPresentation != null && isArrowVisible(myPresentation) ? - (UIUtil.isUnderWin10LookAndFeel() ? getArrowIcon(isEnabled()).getIconWidth() + JBUI.scale(6): ICON_SIZE.get()) : 0) + (UIUtil.isUnderWin10LookAndFeel() ? getArrowIcon(isEnabled()).getIconWidth() + JBUIScale.scale(6) : ICON_SIZE.get()) : 0) + (StringUtil.isNotEmpty(getText()) ? getIconTextGap() : 0); - Dimension size = new Dimension(width, isSmallVariant() ? JBUI.scale(24) : Math.max(JBUI.scale(24), prefSize.height)); + Dimension size = new Dimension(width, isSmallVariant() ? JBUIScale.scale(24) : Math.max(JBUIScale.scale(24), prefSize.height)); JBInsets.addTo(size, getMargin()); return size; } @@ -345,7 +346,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent if (UIUtil.isUnderWin10LookAndFeel()) { Icon icon = getArrowIcon(isEnabled()); - int x = getWidth() - icon.getIconWidth() - getInsets().right - getMargin().right - JBUI.scale(3); + int x = getWidth() - icon.getIconWidth() - getInsets().right - getMargin().right - JBUIScale.scale(3); int y = (getHeight() - icon.getIconHeight()) / 2; icon.paintIcon(null, g, x, y); } @@ -363,9 +364,9 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent g2.setColor(JBUI.CurrentTheme.Arrow.foregroundColor(isEnabled())); Path2D arrow = new Path2D.Float(Path2D.WIND_EVEN_ODD); - arrow.moveTo(JBUI.scale(3.5f), JBUI.scale(6f)); - arrow.lineTo(JBUI.scale(12.5f), JBUI.scale(6f)); - arrow.lineTo(JBUI.scale(8f), JBUI.scale(11f)); + arrow.moveTo(JBUIScale.scale(3.5f), JBUIScale.scale(6f)); + arrow.lineTo(JBUIScale.scale(12.5f), JBUIScale.scale(6f)); + arrow.lineTo(JBUIScale.scale(8f), JBUIScale.scale(11f)); arrow.closePath(); g2.fill(arrow); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java index f1604e748780..118d55be7813 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java @@ -16,11 +16,10 @@ import javax.swing.*; import javax.swing.plaf.basic.BasicComboBoxEditor; import javax.swing.plaf.basic.ComboPopup; import javax.swing.table.TableCellEditor; +import javax.swing.text.DefaultEditorKit; +import javax.swing.text.JTextComponent; import java.awt.*; -import java.awt.event.AWTEventListener; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.WindowEvent; +import java.awt.event.*; /** * Due to many bugs and "features" in {@link JComboBox} implementation we provide @@ -76,7 +75,51 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventLis private void init(int width) { myMinimumAndPreferredWidth = width; registerCancelOnEscape(); - UIUtil.installComboBoxCopyAction(this); + installComboBoxCopyAction(this); + } + + private static void installComboBoxCopyAction(@NotNull JComboBox comboBox) { + final ComboBoxEditor editor = comboBox.getEditor(); + final Component editorComponent = editor != null ? editor.getEditorComponent() : null; + if (!(editorComponent instanceof JTextComponent)) return; + final InputMap inputMap = ((JTextComponent)editorComponent).getInputMap(); + for (KeyStroke keyStroke : inputMap.allKeys()) { + if (DefaultEditorKit.copyAction.equals(inputMap.get(keyStroke))) { + comboBox.getInputMap().put(keyStroke, DefaultEditorKit.copyAction); + } + } + comboBox.getActionMap().put(DefaultEditorKit.copyAction, new AbstractAction() { + @Override + public void actionPerformed(final ActionEvent e) { + if (!(e.getSource() instanceof JComboBox)) return; + final JComboBox comboBox = (JComboBox)e.getSource(); + final String text; + final Object selectedItem = comboBox.getSelectedItem(); + if (selectedItem instanceof String) { + text = (String)selectedItem; + } + else { + final Component component = + comboBox.getRenderer().getListCellRendererComponent(new JList(), selectedItem, 0, false, false); + if (component instanceof JLabel) { + text = ((JLabel)component).getText(); + } + else if (component != null) { + final String str = component.toString(); + // skip default Component.toString and handle SimpleColoredComponent case + text = str == null || str.startsWith(component.getClass().getName() + "[") ? null : str; + } + else { + text = null; + } + } + if (text != null) { + final JTextField textField = new JTextField(text); + textField.selectAll(); + textField.copy(); + } + } + }); } public static void registerTableCellEditor(@NotNull JComboBox comboBox, @NotNull TableCellEditor cellEditor) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java index 91c6a6536791..863a160bc8da 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java @@ -1,10 +1,11 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.ui; import com.intellij.icons.AllIcons; import com.intellij.openapi.ui.popup.*; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -78,7 +79,7 @@ public class ComboBoxTableRenderer extends JLabel implements TableCellRendere } private static Dimension addIconSize(final Dimension d) { - return new Dimension(d.width + AllIcons.General.ArrowDown.getIconWidth() + JBUI.scale(2), + return new Dimension(d.width + AllIcons.General.ArrowDown.getIconWidth() + JBUIScale.scale(2), Math.max(d.height, AllIcons.General.ArrowDown.getIconHeight())); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComponentValidator.java b/platform/platform-api/src/com/intellij/openapi/ui/ComponentValidator.java index e3685a32fbfe..ccf2819d1866 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComponentValidator.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComponentValidator.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.ui; import com.intellij.openapi.Disposable; @@ -9,8 +9,10 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.ColorUtil; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.ui.JBEmptyBorder; import com.intellij.util.ui.JBUI; @@ -123,7 +125,7 @@ public class ComponentValidator { }; PropertyChangeListener ancestorListener = e -> { - Window w = (Window)UIUtil.findParentByCondition((Component)e.getSource(), v -> v instanceof Window); + Window w = (Window)ComponentUtil.findParentByCondition((Component)e.getSource(), v -> v instanceof Window); if (w != null) { if (e.getNewValue() != null) { w.addComponentListener(componentListener); @@ -133,7 +135,7 @@ public class ComponentValidator { } }; - Window w = (Window)UIUtil.findParentByCondition(component, v -> v instanceof Window); + Window w = (Window)ComponentUtil.findParentByCondition(component, v -> v instanceof Window); if (w != null) { w.addComponentListener(componentListener); } else { @@ -296,7 +298,7 @@ public class ComponentValidator { popup = popupBuilder.createPopup(); Insets i = validationInfo.component.getInsets(); - Point point = new Point(JBUI.scale(40), i.top - JBUI.scale(6) - popupSize.height); + Point point = new Point(JBUIScale.scale(40), i.top - JBUIScale.scale(6) - popupSize.height); popupLocation = new RelativePoint(validationInfo.component, point); popup.show(popupLocation); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 77b24bb15866..ff8924a9fab6 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -34,6 +34,7 @@ import com.intellij.ui.components.JBOptionButton; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.mac.TouchbarDataKeys; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.*; @@ -607,7 +608,7 @@ public abstract class DialogWrapper { JComponent doNotAskCheckbox = createDoNotAskCheckbox(); JPanel lrButtonsPanel = new NonOpaquePanel(new GridBagLayout()); - Insets insets = SystemInfo.isMacOSLeopard && UIUtil.isUnderIntelliJLaF() ? JBUI.insets(0, 8) : JBUI.emptyInsets(); + Insets insets = SystemInfo.isMacOSLeopard && UIUtil.isUnderIntelliJLaF() ? JBInsets.create(0, 8) : JBUI.emptyInsets(); if (!rightSideButtons.isEmpty() || !leftSideButtons.isEmpty()) { GridBag bag = new GridBag().setDefaultInsets(insets); @@ -694,7 +695,8 @@ public abstract class DialogWrapper { buttonsPanel.add(button); if (i < buttons.size() - 1) { - int gap = UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF() ? BASE_BUTTON_GAP.get() - insets.left - insets.right : JBUI.scale(8); + int gap = UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF() ? BASE_BUTTON_GAP.get() - insets.left - insets.right : JBUIScale + .scale(8); buttonsPanel.add(Box.createRigidArea(new Dimension(gap, 0))); } } @@ -2036,7 +2038,7 @@ public abstract class DialogWrapper { private Border createErrorTextBorder() { Border border = createContentPaneBorder(); Insets contentInsets = border != null ? border.getBorderInsets(null) : JBUI.emptyInsets(); - Insets baseInsets = JBUI.insets(16, 13); + Insets baseInsets = JBInsets.create(16, 13); //noinspection UseDPIAwareBorders: Insets are already scaled, so use raw version. return new EmptyBorder(baseInsets.top, diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index 087e8ad29a90..e6fd5f185219 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -22,7 +22,7 @@ import com.intellij.ui.mac.MacMessages; import com.intellij.util.Function; import com.intellij.util.PairFunction; import com.intellij.util.execution.ParametersListUtil; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.UI; import com.intellij.util.ui.UIUtil; import org.intellij.lang.annotations.MagicConstant; @@ -1487,7 +1487,7 @@ public class Messages { protected JTextComponent createTextFieldComponent() { JTextField field = new JTextField(30); - field.setMargin(JBUI.insets(0, 5)); + field.setMargin(JBInsets.create(0, 5)); return field; } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/OnePixelDivider.java b/platform/platform-api/src/com/intellij/openapi/ui/OnePixelDivider.java index 3812c55745d8..71e4316d070e 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/OnePixelDivider.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/OnePixelDivider.java @@ -10,7 +10,7 @@ import com.intellij.openapi.wm.IdeGlassPane; import com.intellij.openapi.wm.IdeGlassPaneUtil; import com.intellij.ui.JBColor; import com.intellij.ui.OnePixelSplitter; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.UIUtil; import javax.swing.*; @@ -108,7 +108,7 @@ public class OnePixelDivider extends Divider { OnePixelDivider d = OnePixelDivider.this; if ((vertical ? p.x : p.y) < 0 || vertical && p.x > d.getWidth() || !vertical && p.y > d.getHeight()) return false; int r = Math.abs(vertical ? p.y : p.x); - return r < JBUI.scale(Registry.intValue("ide.splitter.mouseZone")); + return r < JBUIScale.scale(Registry.intValue("ide.splitter.mouseZone")); } @Override diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java b/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java index 491b373627d7..b360b8c7d940 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.ui; import com.intellij.icons.AllIcons; @@ -24,7 +10,9 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeGlassPane; import com.intellij.openapi.wm.IdeGlassPaneUtil; import com.intellij.ui.ClickListener; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.UIBundle; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.EventDispatcher; import com.intellij.util.ReflectionUtil; import com.intellij.util.ui.EmptyIcon; @@ -228,7 +216,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable { } public void setDividerMouseZoneSize(int size) { - myDividerZone = JBUI.scale(size); + myDividerZone = JBUIScale.scale(size); } public boolean isHonorMinimumSize() { @@ -685,10 +673,10 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable { Point point = SwingUtilities.convertPoint(this, p, window); Component component = UIUtil.getDeepestComponentAt(window, point.x, point.y); List components = Arrays.asList(myFirstComponent, myFirstDivider, myInnerComponent, myLastDivider, myLastComponent); - if (UIUtil.findParentByCondition(component, c -> c != null && components.contains(c)) == null) return false; + if (ComponentUtil.findParentByCondition(component, c -> c != null && components.contains(c)) == null) return false; } - int dndOff = myIsOnePixel ? JBUI.scale(Registry.intValue("ide.splitter.mouseZone")) / 2 : 0; + int dndOff = myIsOnePixel ? JBUIScale.scale(Registry.intValue("ide.splitter.mouseZone")) / 2 : 0; if (myVerticalSplit) { if (p.x >= 0 && p.x < getWidth()) { if (getHeight() > 0) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/cellvalidators/CellTooltipManager.java b/platform/platform-api/src/com/intellij/openapi/ui/cellvalidators/CellTooltipManager.java index 87fc2226f32b..51a93dfb025e 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/cellvalidators/CellTooltipManager.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/cellvalidators/CellTooltipManager.java @@ -9,6 +9,7 @@ import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.ApiStatus; @@ -115,7 +116,7 @@ public final class CellTooltipManager { Rectangle cellRect = cellComponentProvider.getCellRect(e); if (!cellRect.equals(this.cellRect)) { this.cellRect = cellRect; - Point point = new Point(this.cellRect.x + JBUI.scale(40), this.cellRect.y - JBUI.scale(6) - popupSize.height); + Point point = new Point(this.cellRect.x + JBUIScale.scale(40), this.cellRect.y - JBUIScale.scale(6) - popupSize.height); SwingUtilities.convertPointToScreen(point, cellComponentProvider.getOwner()); cellPopup.setLocation(point); } @@ -138,7 +139,7 @@ public final class CellTooltipManager { JComponent c = cellComponentProvider.getCellRendererComponent(e); Insets i = c != null ? c.getInsets() : JBUI.emptyInsets(); - Point point = new Point(cellRect.x + JBUI.scale(40), cellRect.y + i.top - JBUI.scale(6) - popupSize.height); + Point point = new Point(cellRect.x + JBUIScale.scale(40), cellRect.y + i.top - JBUIScale.scale(6) - popupSize.height); cellPopup.show(new RelativePoint(cellComponentProvider.getOwner(), point)); } } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/panel/ComponentPanelBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/panel/ComponentPanelBuilder.java index 84bdda46bfe1..53c0946bb051 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/panel/ComponentPanelBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/panel/ComponentPanelBuilder.java @@ -12,6 +12,7 @@ import com.intellij.ui.ContextHelpLabel; import com.intellij.ui.EditorTextComponent; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.panels.NonOpaquePanel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.SystemProperties; import com.intellij.util.ui.JBEmptyBorder; import com.intellij.util.ui.JBUI; @@ -210,7 +211,7 @@ public class ComponentPanelBuilder implements GridBagPanelBuilder { left = UIUtil.getCheckBoxTextHorizontalOffset((JCheckBox)component); // the value returned from this method is already scaled //noinspection UseDPIAwareInsets - return new Insets(top, left, JBUI.scale(bottom), 0); + return new Insets(top, left, JBUIScale.scale(bottom), 0); } else { left = isMacDefault ? 26 : isWin10 ? 17 : 23; diff --git a/platform/platform-api/src/com/intellij/openapi/util/DimensionService.java b/platform/platform-api/src/com/intellij/openapi/util/DimensionService.java index 82fdc108af83..e53325b655c2 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/DimensionService.java +++ b/platform/platform-api/src/com/intellij/openapi/util/DimensionService.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.util; import com.intellij.openapi.components.*; @@ -8,11 +8,13 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; +import com.intellij.ui.ComponentUtil; +import com.intellij.ui.JreHiDpiUtil; import com.intellij.ui.ScreenUtil; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ObjectIntHashMap; import com.intellij.util.containers.hash.LinkedHashMap; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.UIUtil; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -248,7 +250,7 @@ public class DimensionService extends SimpleModificationTracker implements Persi JFrame frame = null; final Component owner = IdeFocusManager.findInstance().getFocusOwner(); if (owner != null) { - frame = UIUtil.getParentOfType(JFrame.class, owner); + frame = ComponentUtil.getParentOfType((Class)JFrame.class, owner); } if (frame == null) { frame = WindowManager.getInstance().findVisibleFrame(); @@ -275,8 +277,8 @@ public class DimensionService extends SimpleModificationTracker implements Persi screen = gd.getDefaultConfiguration().getBounds(); } float scale = 1f; - if (UIUtil.isJreHiDPIEnabled()) { - scale = JBUI.sysScale(gd.getDefaultConfiguration()); + if (JreHiDpiUtil.isJreHiDPIEnabled()) { + scale = JBUIScale.sysScale(gd.getDefaultConfiguration()); // normalize screen bounds screen.setBounds((int)Math.floor(screen.x * scale), (int)Math.floor(screen.y * scale), (int)Math.ceil(screen.width * scale), (int)Math.ceil(screen.height * scale)); diff --git a/platform/platform-api/src/com/intellij/ui/AnActionButton.java b/platform/platform-api/src/com/intellij/ui/AnActionButton.java index b1ce7c4d658f..6b9fb4efeca4 100644 --- a/platform/platform-api/src/com/intellij/ui/AnActionButton.java +++ b/platform/platform-api/src/com/intellij/ui/AnActionButton.java @@ -8,7 +8,6 @@ import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.util.Disposer; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.containers.SmartHashSet; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -132,7 +131,8 @@ public abstract class AnActionButton extends AnAction implements ShortcutProvide private boolean isContextComponentOk() { return myContextComponent == null - || (myContextComponent.isVisible() && UIUtil.getParentOfType(JLayeredPane.class, myContextComponent) != null); + || (myContextComponent.isVisible() && ComponentUtil.getParentOfType((Class)JLayeredPane.class, + (Component)myContextComponent) != null); } @Nullable diff --git a/platform/platform-api/src/com/intellij/ui/AnimatedIcon.java b/platform/platform-api/src/com/intellij/ui/AnimatedIcon.java index 00d0bc9fe324..91ece55d0a07 100644 --- a/platform/platform-api/src/com/intellij/ui/AnimatedIcon.java +++ b/platform/platform-api/src/com/intellij/ui/AnimatedIcon.java @@ -277,7 +277,7 @@ public class AnimatedIcon implements Icon { @Override public final void paintIcon(Component c, Graphics g, int x, int y) { Icon icon = getUpdatedIcon(); - CellRendererPane pane = UIUtil.getParentOfType(CellRendererPane.class, c); + CellRendererPane pane = ComponentUtil.getParentOfType((Class)CellRendererPane.class, c); requestRefresh(pane == null ? c : getRendererOwner(pane.getParent())); icon.paintIcon(c, g, x, y); } diff --git a/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java b/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java index 2e0f0d6de1d4..682f0e2e7a96 100644 --- a/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java +++ b/platform/platform-api/src/com/intellij/ui/ColoredListCellRenderer.java @@ -1,8 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui; import com.intellij.ui.list.ListCellBackgroundSupplier; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -25,7 +25,7 @@ public abstract class ColoredListCellRenderer extends SimpleColoredComponent public ColoredListCellRenderer() { setFocusBorderAroundIcon(true); - getIpad().left = getIpad().right = UIUtil.isUnderWin10LookAndFeel() ? 0 : JBUI.scale(UIUtil.getListCellHPadding()); + getIpad().left = getIpad().right = UIUtil.isUnderWin10LookAndFeel() ? 0 : JBUIScale.scale(UIUtil.getListCellHPadding()); } @Override diff --git a/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java b/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java index 24a5e9bab3dc..707e173a9bc7 100644 --- a/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java +++ b/platform/platform-api/src/com/intellij/ui/EditorNotificationPanel.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui; import com.intellij.codeInsight.intention.*; @@ -36,6 +22,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiFile; import com.intellij.ui.components.panels.HorizontalLayout; import com.intellij.ui.components.panels.NonOpaquePanel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.IncorrectOperationException; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; @@ -58,7 +45,7 @@ import java.util.List; public class EditorNotificationPanel extends JPanel implements IntentionActionProvider, Weighted { protected final JLabel myLabel = new JLabel(); protected final JLabel myGearLabel = new JLabel(); - protected final JPanel myLinksPanel = new NonOpaquePanel(new HorizontalLayout(JBUI.scale(16))); + protected final JPanel myLinksPanel = new NonOpaquePanel(new HorizontalLayout(JBUIScale.scale(16))); protected Color myBackgroundColor; protected ColorKey myBackgroundColorKey; @@ -213,10 +200,10 @@ public class EditorNotificationPanel extends JPanel implements IntentionActionPr return AllIcons.Actions.IntentionBulb; } } - + private static class MyLinkOption implements IntentionAction { private final HyperlinkLabel myLabel; - + private MyLinkOption(HyperlinkLabel label) { myLabel = label; } @@ -250,7 +237,7 @@ public class EditorNotificationPanel extends JPanel implements IntentionActionPr return false; } } - + private static class MySettingsOption implements IntentionAction, Iconable, LowPriorityAction { private final JLabel myLabel; diff --git a/platform/platform-api/src/com/intellij/ui/GuiUtils.java b/platform/platform-api/src/com/intellij/ui/GuiUtils.java index fe7eb8afe31d..a820578b7397 100644 --- a/platform/platform-api/src/com/intellij/ui/GuiUtils.java +++ b/platform/platform-api/src/com/intellij/ui/GuiUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui; import com.intellij.openapi.application.ApplicationManager; @@ -33,7 +19,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.components.JBTextField; import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.intellij.lang.annotations.JdkConstants; import org.jetbrains.annotations.NonNls; @@ -50,18 +35,12 @@ import java.awt.event.ActionListener; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; -public class GuiUtils { +public final class GuiUtils { private static final Logger LOG = Logger.getInstance("#com.intellij.ui.GuiUtils"); - private static final Insets paddingFromDialogBoundaries = new Insets(7, 5, 7, 5); private static final Insets paddingInsideDialog = new Insets(5, 5, 5, 5); - private static final CharFilter NOT_MNEMONIC_CHAR_FILTER = new CharFilter() { - @Override - public boolean accept(char ch) { - return ch != '&' && ch != UIUtil.MNEMONIC; - } - }; + private static final CharFilter NOT_MNEMONIC_CHAR_FILTER = ch -> ch != '&' && ch != UIUtil.MNEMONIC; public static JPanel constructFieldWithBrowseButton(JComponent aComponent, ActionListener aActionListener) { return constructFieldWithBrowseButton(aComponent, aActionListener, 0); @@ -126,11 +105,6 @@ public class GuiUtils { return result; } - public static JPanel makeDialogPanel(JPanel aPanel) { - JPanel emptyBordered = makePaddedPanel(aPanel, paddingFromDialogBoundaries); - return wrapWithBorder(emptyBordered, IdeBorderFactory.createRoundedBorder()); - } - public static JPanel makeTitledPanel(JComponent aComponent, String aTitle) { JPanel result = makePaddedPanel(aComponent, false, true, false, true); return wrapWithBorder(result, IdeBorderFactory.createTitledBorder(aTitle)); @@ -182,24 +156,6 @@ public class GuiUtils { aRight ? paddingInsideDialog.right : 0)); } - public static void setAdditionalIcon(JRadioButton button, Icon icon) { - final Icon defaultIcon = UIUtil.getRadioButtonIcon(); - LayeredIcon deficon = new LayeredIcon(2); - deficon.setIcon(defaultIcon, 0); - deficon.setIcon(icon, 1, defaultIcon.getIconWidth() + JBUI.scale(5), 0); - button.setIcon(deficon); - - LayeredIcon pressed = new LayeredIcon(2); - pressed.setIcon(defaultIcon, 0); - pressed.setIcon(icon, 1, defaultIcon.getIconWidth() + JBUI.scale(5), 0); - button.setPressedIcon(pressed); - - LayeredIcon selected = new LayeredIcon(2); - selected.setIcon(defaultIcon, 0); - selected.setIcon(icon, 1, defaultIcon.getIconWidth() + JBUI.scale(5), 0); - button.setSelectedIcon(selected); - } - public static String getTextWithoutMnemonicEscaping(String text) { return StringUtil.strip(text, NOT_MNEMONIC_CHAR_FILTER); } @@ -213,16 +169,6 @@ public class GuiUtils { return text.indexOf("&"); } - public static void packParentDialog(Component component) { - while (component != null) { - if (component instanceof JDialog) { - component.setVisible(true); - break; - } - component = component.getParent(); - } - } - public static void replaceJSplitPaneWithIDEASplitter(JComponent root) { replaceJSplitPaneWithIDEASplitter(root, false); } diff --git a/platform/platform-api/src/com/intellij/ui/SearchTextField.java b/platform/platform-api/src/com/intellij/ui/SearchTextField.java index d88a6ece70f2..39ab5d89b904 100644 --- a/platform/platform-api/src/com/intellij/ui/SearchTextField.java +++ b/platform/platform-api/src/com/intellij/ui/SearchTextField.java @@ -16,10 +16,10 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBTextField; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Consumer; import com.intellij.util.ReflectionUtil; import com.intellij.util.ui.JBInsets; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -156,7 +156,7 @@ public class SearchTextField extends JPanel { } myTextField.putClientProperty("JTextField.variant", "search"); - myTextField.putClientProperty("JTextField.Search.Gap", JBUI.scale(6)); + myTextField.putClientProperty("JTextField.Search.Gap", JBUIScale.scale(6)); myTextField.putClientProperty("JTextField.Search.CancelAction", (ActionListener)e -> { myTextField.setText(""); onFieldCleared(); diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index ef8c4949152d..b6a5b7ae6863 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -10,6 +10,7 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.paint.EffectPainter; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.*; import org.intellij.lang.annotations.JdkConstants; @@ -93,8 +94,8 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co public SimpleColoredComponent() { myFragments = new ArrayList<>(3); - myIpad = JBUI.insets(1, 2); - myIconTextGap = JBUI.scale(2); + myIpad = JBInsets.create(1, 2); + myIconTextGap = JBUIScale.scale(2); myBorder = JBUI.Borders.empty(1, UIUtil.isUnderWin10LookAndFeel() ? 0 : 1); setOpaque(true); updateUI(); @@ -429,7 +430,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co } protected int getMinHeight() { - return JBUI.scale(16); + return JBUIScale.scale(16); } private Rectangle computePaintArea() { diff --git a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java index 14bcbea48d0b..66dd595ff45f 100644 --- a/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/ui/components/DefaultScrollBarUI.java @@ -1,24 +1,10 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.components; import com.intellij.openapi.util.Key; import com.intellij.ui.components.JBScrollPane.Alignment; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.JBInsets; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.MouseEventAdapter; import com.intellij.util.ui.RegionPainter; import com.intellij.util.ui.UIUtil; @@ -168,7 +154,7 @@ class DefaultScrollBarUI extends ScrollBarUI { } private int scale(int value) { - value = JBUI.scale(value); + value = JBUIScale.scale(value); //noinspection EnumSwitchStatementWhichMissesCases switch (UIUtil.getComponentStyle(myScrollBar)) { case LARGE: diff --git a/platform/platform-api/src/com/intellij/ui/components/JBScrollBar.java b/platform/platform-api/src/com/intellij/ui/components/JBScrollBar.java index aadf004dfe9b..ab0f22827d5f 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBScrollBar.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBScrollBar.java @@ -4,7 +4,7 @@ package com.intellij.ui.components; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.wm.IdeGlassPane.TopComponent; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.RegionPainter; import com.intellij.util.ui.UIUtil; import org.intellij.lang.annotations.JdkConstants; @@ -277,7 +277,7 @@ public class JBScrollBar extends JScrollBar implements TopComponent, Interpolabl } JViewport viewport = getViewport(); Font font = viewport == null ? null : getViewFont(viewport); - int size = font == null ? JBUI.scale(10) : font.getSize(); // assume an unit size + int size = font == null ? JBUIScale.scale(10) : font.getSize(); // assume an unit size return size * rotation * event.getScrollAmount(); } if (ScrollSettings.isHighPrecisionEnabled()) { diff --git a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java index 296b3cc1aa0a..5d5c3d6f9284 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java @@ -4,6 +4,7 @@ package com.intellij.ui.components; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfoRt; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.IdeBorderFactory; import com.intellij.util.ArrayUtil; import com.intellij.util.ReflectionUtil; @@ -176,7 +177,8 @@ public class JBScrollPane extends JScrollPane { } if (!event.isConsumed()) { // try to process a mouse wheel event by outer scroll pane - MouseEventAdapter.redispatch(event, UIUtil.getParentOfType(JScrollPane.class, pane.getParent())); + MouseEventAdapter.redispatch(event, ComponentUtil + .getParentOfType((Class)JScrollPane.class, (Component)pane.getParent())); } } } diff --git a/platform/platform-api/src/com/intellij/ui/components/JBTextArea.java b/platform/platform-api/src/com/intellij/ui/components/JBTextArea.java index 4171b01e929e..da6c444bfef1 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBTextArea.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBTextArea.java @@ -1,8 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.components; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.DocumentAdapter; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -68,7 +68,7 @@ public class JBTextArea extends JTextArea { @Override public void scrollRectToVisible(Rectangle r) { - JViewport viewport = UIUtil.getParentOfType(JViewport.class, this); + JViewport viewport = ComponentUtil.getParentOfType((Class)JViewport.class, (Component)this); if (viewport != null) { r = SwingUtilities.convertRectangle(this, r, viewport); viewport.scrollRectToVisible(r); diff --git a/platform/platform-api/src/com/intellij/ui/components/JBViewport.java b/platform/platform-api/src/com/intellij/ui/components/JBViewport.java index 4168a6d3a5d8..17e518a16cf5 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBViewport.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBViewport.java @@ -8,6 +8,7 @@ import com.intellij.openapi.ui.TypingTarget; import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.registry.Registry; import com.intellij.ui.components.JBScrollPane.Alignment; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; import com.intellij.util.MethodInvocator; import com.intellij.util.ui.*; @@ -552,9 +553,9 @@ public class JBViewport extends JViewport implements ZoomableViewport { int modelRows = model == null ? 0 : model.getSize(); if (modelRows <= 0) { if (fixedWidth <= 0) fixedWidth = Registry.intValue("ide.preferred.scrollable.viewport.fixed.width"); - if (fixedWidth <= 0) fixedWidth = JBUI.scale(256); // scaled value from JDK + if (fixedWidth <= 0) fixedWidth = JBUIScale.scale(256); // scaled value from JDK if (fixedHeight <= 0) fixedHeight = Registry.intValue("ide.preferred.scrollable.viewport.fixed.height"); - if (fixedHeight <= 0) fixedHeight = JBUI.scale(16); // scaled value from JDK + if (fixedHeight <= 0) fixedHeight = JBUIScale.scale(16); // scaled value from JDK } int visibleRows = list.getVisibleRowCount(); if (visibleRows <= 0) visibleRows = Registry.intValue("ide.preferred.scrollable.viewport.visible.rows"); @@ -594,7 +595,7 @@ public class JBViewport extends JViewport implements ZoomableViewport { int modelRows = tree.getRowCount(); if (modelRows <= 0) { if (fixedHeight <= 0) fixedHeight = Registry.intValue("ide.preferred.scrollable.viewport.fixed.height"); - if (fixedHeight <= 0) fixedHeight = JBUI.scale(16); + if (fixedHeight <= 0) fixedHeight = JBUIScale.scale(16); } int visibleRows = tree.getVisibleRowCount(); if (visibleRows <= 0) visibleRows = Registry.intValue("ide.preferred.scrollable.viewport.visible.rows"); diff --git a/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java b/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java index f9187d8e2623..c35abee7e2ca 100644 --- a/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/ui/components/MacScrollBarUI.java @@ -6,6 +6,7 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.registry.RegistryValue; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.mac.foundation.ID; import com.intellij.util.Alarm; import com.intellij.util.NotNullProducer; @@ -126,7 +127,7 @@ final class MacScrollBarUI extends DefaultScrollBarUI { if (event != null && MouseEvent.MOUSE_MOVED == event.getID()) { Object source = event.getSource(); if (source instanceof Component) { - JScrollPane pane = UIUtil.getParentOfType(JScrollPane.class, (Component)source); + JScrollPane pane = ComponentUtil.getParentOfType((Class)JScrollPane.class, (Component)source); if (pane != null) { pauseThumbAnimation(pane.getHorizontalScrollBar()); pauseThumbAnimation(pane.getVerticalScrollBar()); diff --git a/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java b/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java index 0f54f1498861..08ec8e5e49da 100644 --- a/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java +++ b/platform/platform-api/src/com/intellij/ui/components/OnOffButton.java @@ -1,23 +1,9 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.components; import com.intellij.ui.Gray; import com.intellij.ui.JBColor; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.UIUtil; import javax.swing.*; @@ -87,7 +73,7 @@ public class OnOffButton extends JToggleButton { @Override public Dimension getPreferredSize(JComponent c) { - int vGap = JBUI.scale(4); + int vGap = JBUIScale.scale(4); OnOffButton button = (OnOffButton)c; String text = button.getOffText().length() > button.getOnText().length() ? button.getOffText() : button.getOnText(); @@ -104,10 +90,10 @@ public class OnOffButton extends JToggleButton { public void paint(Graphics g, JComponent c) { if (!(c instanceof OnOffButton)) return; - int toggleArc = JBUI.scale(3); - int buttonArc = JBUI.scale(5); - int vGap = JBUI.scale(4); - int hGap = JBUI.scale(3); + int toggleArc = JBUIScale.scale(3); + int buttonArc = JBUIScale.scale(5); + int vGap = JBUIScale.scale(4); + int hGap = JBUIScale.scale(3); OnOffButton button = (OnOffButton)c; Dimension size = button.getSize(); @@ -131,7 +117,7 @@ public class OnOffButton extends JToggleButton { g2.setColor(BORDER_COLOR); g2.drawRoundRect(0, 0, w, h, buttonArc, buttonArc); - int knobWidth = w - SwingUtilities.computeStringWidth(g2.getFontMetrics(), button.getOffText()) - JBUI.scale(2); + int knobWidth = w - SwingUtilities.computeStringWidth(g2.getFontMetrics(), button.getOffText()) - JBUIScale.scale(2); knobWidth = knobWidth > h ? h : knobWidth; int textAscent = g2.getFontMetrics().getAscent(); diff --git a/platform/platform-api/src/com/intellij/ui/components/breadcrumbs/Breadcrumbs.java b/platform/platform-api/src/com/intellij/ui/components/breadcrumbs/Breadcrumbs.java index ac4960c90df1..79c75eccb3f1 100644 --- a/platform/platform-api/src/com/intellij/ui/components/breadcrumbs/Breadcrumbs.java +++ b/platform/platform-api/src/com/intellij/ui/components/breadcrumbs/Breadcrumbs.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.components.breadcrumbs; import com.intellij.openapi.editor.markup.EffectType; @@ -9,10 +9,10 @@ import com.intellij.ui.ColorUtil; import com.intellij.ui.components.JBPanelWithEmptyText; import com.intellij.ui.paint.EffectPainter; import com.intellij.ui.paint.RectanglePainter; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.IconUtil; import com.intellij.util.ui.AbstractLayoutManager; import com.intellij.util.ui.JBInsets; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.MouseEventHandler; import org.intellij.lang.annotations.JdkConstants.FontStyle; import org.jetbrains.annotations.NotNull; @@ -28,7 +28,6 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; import static com.intellij.ide.ui.AntialiasingType.getKeyForCurrentScope; -import static com.intellij.util.ui.UIUtil.DEF_SYSTEM_FONT_SIZE; import static java.util.stream.Collectors.toList; import static javax.swing.SwingConstants.*; import static javax.swing.SwingUtilities.isLeftMouseButton; @@ -274,7 +273,7 @@ public class Breadcrumbs extends JBPanelWithEmptyText { } private static float getFontSize(Font font) { - return font == null ? DEF_SYSTEM_FONT_SIZE : font.getSize2D(); + return font == null ? JBUIScale.DEF_SYSTEM_FONT_SIZE : font.getSize2D(); } private static final AbstractLayoutManager STATELESS_LAYOUT = new AbstractLayoutManager() { @@ -465,7 +464,7 @@ public class Breadcrumbs extends JBPanelWithEmptyText { } if (parent != null && parent.background == background && !Registry.is("editor.breadcrumbs.marker")) { Graphics2D g2 = (Graphics2D)g.create(); - float stroke = JBUI.getFontScale(getFontSize(getFont())); + float stroke = JBUIScale.getFontScale(getFontSize(getFont())); // calculate a visible width of separator (30% of a whole path) int delta = (int)(scale * (.3 * getRightGap() + getLeftGap())); g2.clipRect(bounds.x - delta, bounds.y, Short.MAX_VALUE, bounds.height); diff --git a/platform/platform-api/src/com/intellij/ui/components/fields/ExtendableTextComponent.java b/platform/platform-api/src/com/intellij/ui/components/fields/ExtendableTextComponent.java index 22da55b42ad7..f2efc6a1da38 100644 --- a/platform/platform-api/src/com/intellij/ui/components/fields/ExtendableTextComponent.java +++ b/platform/platform-api/src/com/intellij/ui/components/fields/ExtendableTextComponent.java @@ -1,14 +1,13 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.components.fields; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.util.Collection; import java.util.List; -import static com.intellij.util.ui.JBUI.scale; - /** * @author Konstantin Bulenkov * @author Sergey Malenkov @@ -30,7 +29,7 @@ public interface ExtendableTextComponent { Icon getIcon(boolean hovered); default int getIconGap() { - return scale(5); + return JBUIScale.scale(5); } default int getPreferredSpace() { diff --git a/platform/platform-api/src/com/intellij/ui/components/labels/DropDownLink.java b/platform/platform-api/src/com/intellij/ui/components/labels/DropDownLink.java index 5290687e3839..4a148a6c7a54 100644 --- a/platform/platform-api/src/com/intellij/ui/components/labels/DropDownLink.java +++ b/platform/platform-api/src/com/intellij/ui/components/labels/DropDownLink.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.components.labels; import com.intellij.icons.AllIcons; @@ -6,6 +6,7 @@ import com.intellij.openapi.ui.popup.IPopupChooserBuilder; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Consumer; import com.intellij.util.containers.Convertor; import com.intellij.util.ui.JBUI; @@ -32,7 +33,7 @@ public class DropDownLink extends LinkLabel { setListener((linkLabel, d) -> { JBPopup popup = popupBuilder.convert((DropDownLink)linkLabel); - Point showPoint = new Point(0, getHeight() + JBUI.scale(4)); + Point showPoint = new Point(0, getHeight() + JBUIScale.scale(4)); popup.show(new RelativePoint(this, showPoint)); }, null); @@ -58,7 +59,7 @@ public class DropDownLink extends LinkLabel { } private void init() { - setIconTextGap(JBUI.scale(1)); + setIconTextGap(JBUIScale.scale(1)); setHorizontalAlignment(SwingConstants.LEADING); setHorizontalTextPosition(SwingConstants.LEADING); @@ -67,7 +68,7 @@ public class DropDownLink extends LinkLabel { protected String layoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR) { String result = super.layoutCL(label, fontMetrics, text, icon, viewR, iconR, textR); - iconR.y += JBUI.scale(1); + iconR.y += JBUIScale.scale(1); return result; } }); @@ -96,7 +97,7 @@ public class DropDownLink extends LinkLabel { } private Dimension recomputeSize(@NotNull Dimension size) { - size.height = Math.max(size.height, JBUI.scale(22)); + size.height = Math.max(size.height, JBUIScale.scale(22)); size.width = Math.max(size.width, owner.getPreferredSize().width); return size; } diff --git a/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java b/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java index 227fc6e6c180..f9e801247560 100644 --- a/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java +++ b/platform/platform-api/src/com/intellij/ui/paint/EffectPainter2D.java @@ -1,11 +1,13 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.paint; import com.intellij.ide.ui.UISettings; import com.intellij.openapi.util.registry.Registry; +import com.intellij.ui.JreHiDpiUtil; import com.intellij.ui.paint.PaintUtil.RoundingMode; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.ImageUtil; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.StartupUiUtil; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.WavePainter2D; import org.jetbrains.annotations.NotNull; @@ -14,7 +16,8 @@ import org.jetbrains.annotations.TestOnly; import java.awt.*; import java.awt.font.LineMetrics; -import java.awt.geom.*; +import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; @@ -65,7 +68,7 @@ public enum EffectPainter2D implements RegionPainter2D { @Override public void paint(Graphics2D g, double x, double y, double width, double height, Font font) { if (!Registry.is("ide.text.effect.new")) { - int h = JBUI.scale(Registry.intValue("editor.bold.underline.height", 2)); + int h = JBUIScale.scale(Registry.intValue("editor.bold.underline.height", 2)); RectanglePainter2D.FILL.paint(g, x, y, width, h); } else { @@ -158,7 +161,7 @@ public enum EffectPainter2D implements RegionPainter2D { if (width > 0 && height > 0) { if (Registry.is("ide.text.effect.new.metrics")) { if (font == null) font = g.getFont(); - RoundingMode roundingMode = !UIUtil.isJreHiDPIEnabled() || painter != WAVE_UNDERSCORE || font.getSize2D() / UISettings.getDefFontSize() > 1 ? + RoundingMode roundingMode = !JreHiDpiUtil.isJreHiDPIEnabled() || painter != WAVE_UNDERSCORE || font.getSize2D() / UISettings.getDefFontSize() > 1 ? RoundingMode.FLOOR : RoundingMode.CEIL; LineMetrics metrics = font.getLineMetrics("", g.getFontRenderContext()); double devPixel = PaintUtil.devPixel(g); @@ -183,7 +186,7 @@ public enum EffectPainter2D implements RegionPainter2D { y += height - max; height = max; if (thickness > 1 && height > 3) { - thickness = JBUI.scale((float)thickness); + thickness = JBUIScale.scale((float)thickness); } } drawLineCentered(g, x, y, width, height, thickness, painter); @@ -197,14 +200,14 @@ public enum EffectPainter2D implements RegionPainter2D { } private static double maybeScaleFontMetricsThickness(double fontMetricsThickness, @NotNull Font font) { - float fontScale = JBUI.getFontScale(font.getSize2D()); + float fontScale = JBUIScale.getFontScale(font.getSize2D()); float normalizedFontScale = font.getSize2D() / UISettings.getDefFontSize(); if (normalizedFontScale > 1) { // k==1.0 with normalizedFontScale==1.0, k->0.5 fast enough with normalizedFontScale increasing double k = 1 / (Math.pow(normalizedFontScale, 2) + 1) + 0.5; fontScale *= k; } - if (!UIUtil.isJreHiDPIEnabled()) fontScale = Math.max(1, Math.round(fontScale)); + if (!JreHiDpiUtil.isJreHiDPIEnabled()) fontScale = Math.max(1, Math.round(fontScale)); return Math.max(fontMetricsThickness, fontScale); } @@ -241,7 +244,7 @@ public enum EffectPainter2D implements RegionPainter2D { @Override void paintImage(Graphics2D g, double width, double height, double period) { - Double round = period <= 2 && !UIUtil.isJreHiDPI(g) ? null : period; + Double round = period <= 2 && !JreHiDpiUtil.isJreHiDPI(g) ? null : period; for (int dx = 0; dx < width; dx += period + period) { RectanglePainter2D.FILL.paint(g, dx, 0, period, period, round, LinePainter2D.StrokeType.INSIDE, 1, RenderingHints.VALUE_ANTIALIAS_DEFAULT); } @@ -322,8 +325,8 @@ public enum EffectPainter2D implements RegionPainter2D { @Nullable BufferedImage getImage(@NotNull Graphics2D g, Color color, double height) { - ConcurrentHashMap cache = UIUtil.isJreHiDPI(g) ? myHiDPICache : myNormalCache; - int key = Objects.hash(color.getRGB(), JBUI.sysScale(g), height); + ConcurrentHashMap cache = JreHiDpiUtil.isJreHiDPI(g) ? myHiDPICache : myNormalCache; + int key = Objects.hash(color.getRGB(), JBUIScale.sysScale(g), height); BufferedImage image = cache.get(key); if (image == null) { image = createImage(g, color, height); @@ -358,7 +361,7 @@ public enum EffectPainter2D implements RegionPainter2D { double offset = (x % period + period) % period; // normalize g.translate(-offset, 0); for (double dx = -offset; dx < width; dx += period) { - UIUtil.drawImage(g, image, 0, 0, null); + StartupUiUtil.drawImage(g, image, 0, 0, null); g.translate(period, 0); } g.dispose(); diff --git a/platform/platform-api/src/com/intellij/ui/table/JBTable.java b/platform/platform-api/src/com/intellij/ui/table/JBTable.java index f2f87b0337c8..79e9a3620beb 100644 --- a/platform/platform-api/src/com/intellij/ui/table/JBTable.java +++ b/platform/platform-api/src/com/intellij/ui/table/JBTable.java @@ -9,6 +9,7 @@ import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.*; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.SpeedSearchSupply; import com.intellij.ui.treeStructure.treetable.TreeTable; import com.intellij.ui.treeStructure.treetable.TreeTableModel; @@ -1144,7 +1145,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component } private boolean isOnBorder(@NotNull MouseEvent e) { - return Math.abs(header.getTable().getWidth() - e.getPoint().x) <= JBUI.scale(3); + return Math.abs(header.getTable().getWidth() - e.getPoint().x) <= JBUIScale.scale(3); } private boolean canMoveOrResizeColumn(@NotNull MouseEvent e) { diff --git a/platform/platform-api/src/com/intellij/ui/tabs/TabsUtil.java b/platform/platform-api/src/com/intellij/ui/tabs/TabsUtil.java index 6b332c77aab0..8099e5b2cb2f 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/TabsUtil.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/TabsUtil.java @@ -2,6 +2,7 @@ package com.intellij.ui.tabs; import com.intellij.ide.ui.UISettings; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.JBValue; import com.intellij.util.ui.UIUtil; @@ -14,7 +15,7 @@ import java.awt.*; */ public class TabsUtil { public static final JBValue TAB_VERTICAL_PADDING = new JBValue.Float(2); - public static final int NEW_TAB_VERTICAL_PADDING = JBUI.scale(2); + public static final int NEW_TAB_VERTICAL_PADDING = JBUIScale.scale(2); private TabsUtil() { } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index b06b39f5dd33..6a7f83e57943 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -17,6 +17,7 @@ import com.intellij.openapi.wm.IdeGlassPane; import com.intellij.openapi.wm.IdeGlassPaneUtil; import com.intellij.ui.*; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.switcher.QuickActionProvider; import com.intellij.ui.tabs.*; import com.intellij.ui.tabs.impl.singleRow.ScrollableSingleRowLayout; @@ -55,8 +56,8 @@ public class JBTabsImpl extends JComponent UISettingsListener, QuickActionProvider, Accessible { @NonNls public static final Key SIDE_TABS_SIZE_LIMIT_KEY = Key.create("SIDE_TABS_SIZE_LIMIT_KEY"); - static final int MIN_TAB_WIDTH = JBUI.scale(75); - public static final int DEFAULT_MAX_TAB_WIDTH = JBUI.scale(300); + static final int MIN_TAB_WIDTH = JBUIScale.scale(75); + public static final int DEFAULT_MAX_TAB_WIDTH = JBUIScale.scale(300); public static final Color MAC_AQUA_BG_COLOR = Gray._200; private static final Comparator ABC_COMPARATOR = (o1, o2) -> StringUtil.naturalCompare(o1.getText(), o2.getText()); diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java index 2878a96cf9e9..528626a04082 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java @@ -8,6 +8,7 @@ import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.ui.*; import com.intellij.ui.components.panels.Wrapper; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.tabs.*; import com.intellij.ui.tabs.impl.table.TableLayout; import com.intellij.util.PairConsumer; @@ -243,8 +244,8 @@ public class TabLabel extends JPanel implements Accessible { myCentered = toCenter; } - - + + public void paintOffscreen(Graphics g) { synchronized (getTreeLock()) { @@ -357,7 +358,7 @@ public class TabLabel extends JPanel implements Accessible { switch (pos) { case top: case bottom: - if (myTabs.hasUnderline()) size.height += myTabs.getActiveTabUnderlineHeight() - JBUI.scale(1); + if (myTabs.hasUnderline()) size.height += myTabs.getActiveTabUnderlineHeight() - JBUIScale.scale(1); break; case left: case right: diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/CompressibleSingleRowLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/CompressibleSingleRowLayout.java index 00f2a7865013..3cb29f5f3972 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/CompressibleSingleRowLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/CompressibleSingleRowLayout.java @@ -6,7 +6,7 @@ import com.intellij.ui.tabs.TabInfo; import com.intellij.ui.tabs.impl.JBTabsImpl; import com.intellij.ui.tabs.impl.TabLabel; import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBFont; import java.awt.*; import java.util.Arrays; @@ -44,7 +44,7 @@ public class CompressibleSingleRowLayout extends SingleRowLayout { final TabLabel label = myTabs.myInfo2Label.get(layout.get(i)); if (maxGridSize == 0) { Font font = label.getLabelComponent().getFont(); - maxGridSize = GraphicsUtil.stringWidth("m", font == null ? JBUI.Fonts.label() : font) * myTabs.tabMSize(); + maxGridSize = GraphicsUtil.stringWidth("m", font == null ? JBFont.label() : font) * myTabs.tabMSize(); } int lengthIncrement = label.getPreferredSize().width; lengths[i] = lengthIncrement; diff --git a/platform/platform-api/src/com/intellij/ui/tabs/newImpl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/newImpl/JBTabsImpl.java index a845198ae734..422e51df3212 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/newImpl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/newImpl/JBTabsImpl.java @@ -19,6 +19,7 @@ import com.intellij.ui.Gray; import com.intellij.ui.GuiUtils; import com.intellij.ui.ScreenUtil; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.switcher.QuickActionProvider; import com.intellij.ui.tabs.*; import com.intellij.ui.tabs.newImpl.singleRow.ScrollableSingleRowLayout; @@ -49,16 +50,16 @@ import java.beans.PropertyChangeListener; import java.util.List; import java.util.*; -import static com.intellij.openapi.wm.IdeFocusManager.getGlobalInstance; import static com.intellij.openapi.rd.DisposableExKt.createLifetime; +import static com.intellij.openapi.wm.IdeFocusManager.getGlobalInstance; public class JBTabsImpl extends JComponent implements JBTabsEx, PropertyChangeListener, TimerListener, DataProvider, PopupMenuListener, Disposable, JBTabsPresentation, Queryable, UISettingsListener, QuickActionProvider, Accessible { @NonNls public static final Key SIDE_TABS_SIZE_LIMIT_KEY = Key.create("SIDE_TABS_SIZE_LIMIT_KEY"); - static final int MIN_TAB_WIDTH = JBUI.scale(75); - public static final int DEFAULT_MAX_TAB_WIDTH = JBUI.scale(300); + static final int MIN_TAB_WIDTH = JBUIScale.scale(75); + public static final int DEFAULT_MAX_TAB_WIDTH = JBUIScale.scale(300); public static final Color MAC_AQUA_BG_COLOR = Gray._200; private static final Comparator ABC_COMPARATOR = (o1, o2) -> StringUtil.naturalCompare(o1.getText(), o2.getText()); diff --git a/platform/platform-api/src/com/intellij/ui/tabs/newImpl/TabLabel.java b/platform/platform-api/src/com/intellij/ui/tabs/newImpl/TabLabel.java index 042c18b727f5..e7ef8ee22a1d 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/newImpl/TabLabel.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/newImpl/TabLabel.java @@ -9,6 +9,7 @@ import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.ui.*; import com.intellij.ui.components.panels.Wrapper; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.tabs.JBTabPainter; import com.intellij.ui.tabs.JBTabsEx; import com.intellij.ui.tabs.TabInfo; @@ -213,10 +214,10 @@ public class TabLabel extends JPanel implements Accessible, Disposable { Insets insets = super.getInsets(); if (myTabs.isEditorTabs() && UISettings.getShadowInstance().getShowCloseButton() && hasIcons()) { if (UISettings.getShadowInstance().getCloseTabButtonOnTheRight()) { - insets.right -= JBUI.scale(4); + insets.right -= JBUIScale.scale(4); } else { - insets.left -= JBUI.scale(4); + insets.left -= JBUIScale.scale(4); } } return insets; diff --git a/platform/platform-api/src/com/intellij/ui/tabs/newImpl/singleRow/CompressibleSingleRowLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/newImpl/singleRow/CompressibleSingleRowLayout.java index d45748f24d5c..07a8b795ef37 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/newImpl/singleRow/CompressibleSingleRowLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/newImpl/singleRow/CompressibleSingleRowLayout.java @@ -6,12 +6,12 @@ import com.intellij.ui.tabs.TabInfo; import com.intellij.ui.tabs.newImpl.JBTabsImpl; import com.intellij.ui.tabs.newImpl.TabLabel; import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.JBFont; +import java.awt.*; import java.util.Arrays; import java.util.Iterator; import java.util.List; -import java.awt.Font; public class CompressibleSingleRowLayout extends SingleRowLayout { public CompressibleSingleRowLayout(JBTabsImpl tabs) { @@ -44,7 +44,7 @@ public class CompressibleSingleRowLayout extends SingleRowLayout { final TabLabel label = myTabs.myInfo2Label.get(layout.get(i)); if (maxGridSize == 0) { Font font = label.getLabelComponent().getFont(); - maxGridSize = GraphicsUtil.stringWidth("m", font == null ? JBUI.Fonts.label() : font) * myTabs.tabMSize(); + maxGridSize = GraphicsUtil.stringWidth("m", font == null ? JBFont.label() : font) * myTabs.tabMSize(); } int lengthIncrement = label.getPreferredSize().width; lengths[i] = lengthIncrement; diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java b/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java index d265ef6fa008..45e2e285659c 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/treetable/TreeTable.java @@ -1,24 +1,10 @@ -// Copyright 2000-2017 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. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.treeStructure.treetable; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.TableUtil; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.table.JBTable; -import com.intellij.util.ObjectUtils; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.accessibility.ScreenReader; import org.jetbrains.annotations.NotNull; @@ -31,7 +17,6 @@ import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -141,7 +126,7 @@ public class TreeTable extends JBTable { // And update the height of the trees row to match that of the table. if (myTree.getRowHeight() < 1) { - setRowHeight(JBUI.scale(18)); // Metal looks better like this. + setRowHeight(JBUIScale.scale(18)); // Metal looks better like this. } else { setRowHeight(getRowHeight()); diff --git a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java index f833eed3656b..a540c67d3c03 100644 --- a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java @@ -14,6 +14,7 @@ import com.intellij.ui.LightColors; import com.intellij.ui.components.JBScrollBar; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBScrollPane.Alignment; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.ReflectionUtil; @@ -589,7 +590,8 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { } protected int getThickness() { - return JBUI.scale(isMacOverlayScrollbar() ? 15 : 13); + int i = isMacOverlayScrollbar() ? 15 : 13; + return JBUIScale.scale(i); } @Override @@ -713,7 +715,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { bounds.height -= 2; } if (SystemInfoRt.isMac) { - int max = JBUI.scale(12); + int max = JBUIScale.scale(12); if (max < bounds.width && bounds.width < bounds.height) { bounds.x += (bounds.width - max) / 2; bounds.width = max; @@ -752,7 +754,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { @Deprecated protected int getThumbOffset(int value) { // com.intellij.ui.components.AbstractScrollBarUI.scale - float scale = JBUI.scale(10); + float scale = JBUIScale.scale(10); //noinspection EnumSwitchStatementWhichMissesCases switch (UIUtil.getComponentStyle(scrollbar)) { case LARGE: @@ -795,7 +797,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI { int baseSize = vertical ? baseBounds.width : baseBounds.height; int maxSize = baseSize - (thumb ? borderSize * 2 : 0); - int minSize = Math.min(baseSize / 2, JBUI.scale(7)) + (thumb ? 0 : borderSize * 2); + int minSize = Math.min(baseSize / 2, JBUIScale.scale(7)) + (thumb ? 0 : borderSize * 2); int currentSize = minSize + (int)(myMouseOverScrollbarExpandLevel * (maxSize - minSize)); diff --git a/platform/platform-api/src/com/intellij/util/ui/StatusText.java b/platform/platform-api/src/com/intellij/util/ui/StatusText.java index d4d6aaebee92..2b31c4b9a72d 100644 --- a/platform/platform-api/src/com/intellij/util/ui/StatusText.java +++ b/platform/platform-api/src/com/intellij/util/ui/StatusText.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.ui; @@ -21,6 +7,7 @@ import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.UIBundle; import com.intellij.ui.components.JBViewport; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -286,7 +273,7 @@ public abstract class StatusText { Rectangle primaryBounds = adjustComponentBounds(myComponent, bounds); Rectangle secondaryBounds = adjustComponentBounds(mySecondaryComponent, bounds); if (myVerticalFlow) { - secondaryBounds.y += primaryBounds.height + JBUI.scale(Y_GAP); + secondaryBounds.y += primaryBounds.height + JBUIScale.scale(Y_GAP); } paintComponentInBounds(myComponent, g, primaryBounds); @@ -336,7 +323,7 @@ public abstract class StatusText { if (myVerticalFlow) { return new Dimension(Math.max(componentSize.width, secondaryComponentSize.width), - componentSize.height + secondaryComponentSize.height + JBUI.scale(Y_GAP)); + componentSize.height + secondaryComponentSize.height + JBUIScale.scale(Y_GAP)); } else { return new Dimension(componentSize.width + secondaryComponentSize.width, diff --git a/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java b/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java index e0ea2291e47c..374e2a8f34b8 100644 --- a/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java +++ b/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.ui.tree; import com.intellij.ide.util.treeView.AbstractTreeBuilder; @@ -13,6 +13,7 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.ScrollingUtil; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.tree.TreeVisitor; import com.intellij.ui.treeStructure.Tree; import com.intellij.util.ObjectUtils; @@ -21,7 +22,6 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.JBIterable; import com.intellij.util.containers.JBTreeTraverser; import com.intellij.util.containers.TreeTraversal; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -39,8 +39,8 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.lang.reflect.Method; -import java.util.*; import java.util.List; +import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Function; @@ -1518,7 +1518,7 @@ public final class TreeUtil { } else { bounds.width = Math.min(bounds.width, width / 2); - bounds.x -= JBUI.scale(20); // TODO: calculate a control width + bounds.x -= JBUIScale.scale(20); // TODO: calculate a control width if (bounds.x < 0) { bounds.width += bounds.x; bounds.x = 0; diff --git a/platform/platform-impl/src/com/intellij/application/options/schemes/AbstractDescriptionAwareSchemesPanel.java b/platform/platform-impl/src/com/intellij/application/options/schemes/AbstractDescriptionAwareSchemesPanel.java index 4d2a8312f59f..b0682bedddbe 100644 --- a/platform/platform-impl/src/com/intellij/application/options/schemes/AbstractDescriptionAwareSchemesPanel.java +++ b/platform/platform-impl/src/com/intellij/application/options/schemes/AbstractDescriptionAwareSchemesPanel.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.schemes; import com.intellij.openapi.Disposable; @@ -26,8 +12,8 @@ import com.intellij.ui.ClickListener; import com.intellij.ui.JBColor; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBTextField; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -108,7 +94,7 @@ public abstract class AbstractDescriptionAwareSchemesPanel ext if (myDescriptionTextField.isShowing()) { GraphicsUtil.setupAntialiasing(g); g.setColor(JBColor.GRAY); - g.drawString(EditableSchemesCombo.EDITING_HINT, 0, -JBUI.scale(5)); + g.drawString(EditableSchemesCombo.EDITING_HINT, 0, -JBUIScale.scale(5)); } } }; diff --git a/platform/platform-impl/src/com/intellij/application/options/schemes/EditableSchemesCombo.java b/platform/platform-impl/src/com/intellij/application/options/schemes/EditableSchemesCombo.java index d434a39bd1f0..39bb13f96910 100644 --- a/platform/platform-impl/src/com/intellij/application/options/schemes/EditableSchemesCombo.java +++ b/platform/platform-impl/src/com/intellij/application/options/schemes/EditableSchemesCombo.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.application.options.schemes; import com.intellij.openapi.options.Scheme; @@ -7,7 +7,7 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.JBColor; import com.intellij.ui.SimpleTextAttributes; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,8 +48,8 @@ public class EditableSchemesCombo { myRootPanel.add(myComboBox); myNameEditorField = createNameEditorField(); myRootPanel.add(myNameEditorField); - myRootPanel.setPreferredSize(new Dimension(JBUI.scale(COMBO_WIDTH), myNameEditorField.getPreferredSize().height)); - myRootPanel.setMaximumSize(new Dimension(JBUI.scale(COMBO_WIDTH), Short.MAX_VALUE)); + myRootPanel.setPreferredSize(new Dimension(JBUIScale.scale(COMBO_WIDTH), myNameEditorField.getPreferredSize().height)); + myRootPanel.setMaximumSize(new Dimension(JBUIScale.scale(COMBO_WIDTH), Short.MAX_VALUE)); } private JTextField createNameEditorField() { diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java index d9ff728f7296..e9422fe49c32 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.hint; import com.intellij.openapi.application.ApplicationManager; @@ -20,6 +20,7 @@ import com.intellij.reference.SoftReference; import com.intellij.ui.HintHint; import com.intellij.ui.LightweightHint; import com.intellij.ui.ScreenUtil; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -188,17 +189,17 @@ public class EditorFragmentComponent extends JPanel { incrementLine = StringUtil.isWhiteSpace(c); if (!incrementLine || c == '\n') { break; - } + } } if (incrementLine) { startLine++; - } - + } + int endLine = Math.min(document.getLineNumber(range.getEndOffset()) + 1, document.getLineCount() - 1); if (startLine >= endLine) return null; - EditorFragmentComponent fragmentComponent = createEditorFragmentComponent(editor, startLine, endLine, showFolding, true, + EditorFragmentComponent fragmentComponent = createEditorFragmentComponent(editor, startLine, endLine, showFolding, true, useCaretRowBackground); if (showUpward) { @@ -207,7 +208,7 @@ public class EditorFragmentComponent extends JPanel { } final JComponent c = editor.getComponent(); - int x = SwingUtilities.convertPoint(c, new Point(JBUI.scale(-3),0), UIUtil.getRootPane(c)).x; //IDEA-68016 + int x = SwingUtilities.convertPoint(c, new Point(JBUIScale.scale(-3), 0), UIUtil.getRootPane(c)).x; //IDEA-68016 LightweightHint currentHint = SoftReference.dereference(editor.getUserData(CURRENT_HINT)); if (currentHint != null) currentHint.hide(); @@ -232,7 +233,7 @@ public class EditorFragmentComponent extends JPanel { boolean showFolding, boolean showGutter) { return createEditorFragmentComponent(component, editor, startLine, endLine, showFolding, showGutter, true); } - + public static EditorFragmentComponent createEditorFragmentComponent(Editor editor, int startLine, int endLine, @@ -279,8 +280,8 @@ public class EditorFragmentComponent extends JPanel { int lineHeight = editor.getLineHeight(); int overhang = editor.getScrollingModel().getVisibleArea().y - editor.logicalPositionToXY(editor.offsetToLogicalPosition(range.getEndOffset())).y; - int yRelative = overhang > 0 && overhang < lineHeight ? - lineHeight - overhang + JBUI.scale(LINE_BORDER_THICKNESS + EMPTY_BORDER_THICKNESS) : 0; + int yRelative = overhang > 0 && overhang < lineHeight ? + lineHeight - overhang + JBUIScale.scale(LINE_BORDER_THICKNESS + EMPTY_BORDER_THICKNESS) : 0; Point point = SwingUtilities.convertPoint(((EditorEx)editor).getScrollPane().getViewport(), -2, yRelative, layeredPane); return showEditorFragmentHintAt(editor, range, point.y, true, showFolding, hideByAnyKey, true, false); } @@ -288,7 +289,7 @@ public class EditorFragmentComponent extends JPanel { public static Color getBackgroundColor(Editor editor){ return getBackgroundColor(editor, true); } - + public static Color getBackgroundColor(Editor editor, boolean useCaretRowBackground){ EditorColorsScheme colorsScheme = editor.getColorsScheme(); Color color = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR); diff --git a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java index 7b46c52fd320..aba2254d841e 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/IdeErrorsDialog.java @@ -39,6 +39,7 @@ import com.intellij.ui.*; import com.intellij.ui.components.ComponentsKt; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ExceptionUtil; import com.intellij.util.text.DateFormatUtil; import com.intellij.util.ui.JBUI; @@ -307,7 +308,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene commentPanel.add(commentLabel, BorderLayout.NORTH); commentPanel.add(scrollPane(myCommentArea, 0, 0), BorderLayout.CENTER); - JPanel attachmentsPanel = new JPanel(new BorderLayout(JBUI.scale(5), 0)); + JPanel attachmentsPanel = new JPanel(new BorderLayout(JBUIScale.scale(5), 0)); attachmentsPanel.setBorder(JBUI.Borders.emptyTop(5)); attachmentsPanel.add(attachmentsLabel, BorderLayout.NORTH); attachmentsPanel.add(scrollPane(myAttachmentsList, 150, 350), BorderLayout.WEST); @@ -608,7 +609,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene Container parentComponent = getRootPane(); if (dialogClosed) { - IdeFrame frame = UIUtil.getParentOfType(IdeFrame.class, parentComponent); + IdeFrame frame = ComponentUtil.getParentOfType((Class)IdeFrame.class, (Component)parentComponent); parentComponent = frame != null ? frame.getComponent() : WindowManager.getInstance().findVisibleFrame(); } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index d59b69892dc4..f99d756a6128 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -32,6 +32,7 @@ import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.openapi.wm.impl.FocusManagerImpl; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.mac.touchbar.TouchBarsManager; import com.intellij.util.Alarm; import com.intellij.util.ReflectionUtil; @@ -222,7 +223,8 @@ public final class IdeEventQueue extends EventQueue { case HierarchyEvent.ANCESTOR_MOVED: case HierarchyEvent.ANCESTOR_RESIZED: Object source = event.getSource(); - if (source instanceof Component && null != UIUtil.getParentOfType(CellRendererPane.class, (Component)source)) { + if (source instanceof Component && + ComponentUtil.getParentOfType((Class)CellRendererPane.class, (Component)source) != null) { return true; } } @@ -750,7 +752,7 @@ public final class IdeEventQueue extends EventQueue { final Window eventWindow = we.getWindow(); if (we.getID() == WindowEvent.WINDOW_DEACTIVATED || we.getID() == WindowEvent.WINDOW_LOST_FOCUS) { - Component frame = UIUtil.findUltimateParent(eventWindow); + Component frame = ComponentUtil.findUltimateParent(eventWindow); Component focusOwnerInDeactivatedWindow = eventWindow.getMostRecentFocusOwner(); IdeFrame[] allProjectFrames = WindowManager.getInstance().getAllProjectFrames(); @@ -977,7 +979,7 @@ public final class IdeEventQueue extends EventQueue { //noinspection SSBasedInspection SwingUtilities.invokeLater(() -> { try { - final Window window = UIUtil.getWindow(component); + final Window window = ComponentUtil.getWindow(component); if (window == null || !window.isActive()) { return; } @@ -1010,7 +1012,7 @@ public final class IdeEventQueue extends EventQueue { && e instanceof KeyEvent && e.getID() == KeyEvent.KEY_RELEASED && (((KeyEvent)e).getKeyCode() == KeyEvent.VK_UP || ((KeyEvent)e).getKeyCode() == KeyEvent.VK_DOWN)) { - Component parent = UIUtil.getWindow(((KeyEvent)e).getComponent()); + Component parent = ComponentUtil.getWindow(((KeyEvent)e).getComponent()); if (parent instanceof JDialog) { final JDialog dialog = (JDialog)parent; SwingUtilities.invokeLater(() -> { @@ -1034,7 +1036,7 @@ public final class IdeEventQueue extends EventQueue { public boolean dispatch(@NotNull AWTEvent e) { if (e instanceof KeyEvent && e.getID() == KeyEvent.KEY_PRESSED && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ESCAPE && !getInstance().getPopupManager().isPopupActive()) { - final Component owner = UIUtil.findParentByCondition(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(), + final Component owner = ComponentUtil.findParentByCondition(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(), component -> component instanceof JTable || component instanceof JTree); if (owner instanceof JTable && ((JTable)owner).isEditing()) { diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java index f72ca0f105ad..f8dc4f81da7f 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide; import com.intellij.codeInsight.hint.HintUtil; @@ -26,6 +26,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.panels.Wrapper; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.ui.*; import org.jetbrains.annotations.NonNls; @@ -240,7 +241,7 @@ public class IdeTooltipManager implements Disposable, AWTEventListener, BaseComp Rectangle visibleRect = c.getParent() instanceof JViewport ? ((JViewport)c.getParent()).getViewRect() : c.getVisibleRect(); if (!visibleRect.contains(getPoint())) return false; - JLayeredPane layeredPane = UIUtil.getParentOfType(JLayeredPane.class, c); + JLayeredPane layeredPane = ComponentUtil.getParentOfType((Class)JLayeredPane.class, (Component)c); final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane); final Wrapper wrapper = new Wrapper(pane); @@ -631,7 +632,7 @@ public class IdeTooltipManager implements Disposable, AWTEventListener, BaseComp try { Field field = view.getClass().getDeclaredField("size"); field.setAccessible(true); - field.set(view, JBUI.scale(1)); + field.set(view, JBUIScale.scale(1)); return view; } catch (Exception ignored) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java b/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java index e5bbd6861397..26498b5e9262 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java @@ -34,6 +34,7 @@ import com.intellij.ui.JBColor; import com.intellij.ui.LicensingFacade; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.text.DateFormatUtil; import com.intellij.util.ui.*; @@ -331,13 +332,13 @@ public class AboutPopup { GraphicsConfig config = new GraphicsConfig(g); UISettings.setupAntialiasing(g); - Font labelFont = JBUI.Fonts.label(); + Font labelFont = JBFont.label(); if (SystemInfoRt.isWindows) { labelFont = JBUI.Fonts.create(SystemInfo.isWinVistaOrNewer ? "Segoe UI" : "Tahoma", 14); } int startFontSize = 14; - for (int labelSize = JBUI.scale(startFontSize); labelSize != JBUI.scale(6); labelSize -= 1) { + for (int labelSize = JBUIScale.scale(startFontSize); labelSize != JBUIScale.scale(6); labelSize -= 1) { myLinks.clear(); g2.setPaint(myColor); myImage.paintIcon(this, g2, 0, 0); @@ -721,7 +722,7 @@ public class AboutPopup { @Override protected JComponent createCenterPanel() { - JPanel centerPanel = new JPanel(new BorderLayout(JBUI.scale(5), JBUI.scale(5))); + JPanel centerPanel = new JPanel(new BorderLayout(JBUIScale.scale(5), JBUIScale.scale(5))); JEditorPane viewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK); viewer.setFocusable(true); @@ -736,7 +737,7 @@ public class AboutPopup { StyleSheet styleSheet = ((HTMLDocument)viewer.getDocument()).getStyleSheet(); styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}"); styleSheet.addRule("body {margin-top:0;padding-top:0;}"); - styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(14) + "pt;}"); + styleSheet.addRule("body {font-size:" + JBUIScale.scaleFontSize((float)14) + "pt;}"); viewer.setCaretPosition(0); viewer.setBorder(JBUI.Borders.empty(0, 5, 5, 5)); @@ -760,7 +761,7 @@ public class AboutPopup { StringBuffer sb = new StringBuffer(); while (matcher.find()) { - matcher.appendReplacement(sb, JBUI.scale(Integer.parseInt(matcher.group(1))) + "px"); + matcher.appendReplacement(sb, JBUIScale.scale(Integer.parseInt(matcher.group(1))) + "px"); } matcher.appendTail(sb); @@ -772,7 +773,7 @@ public class AboutPopup { dialog.setTitle(String.format("Third-Party Software Used by %s %s", ApplicationNamesInfo.getInstance().getFullProductName(), ApplicationInfo.getInstance().getFullVersion())); - dialog.setSize(JBUI.scale(750), JBUI.scale(650)); + dialog.setSize(JBUIScale.scale(750), JBUIScale.scale(650)); dialog.show(); } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java index d3def2c24f23..f39c45e83402 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java @@ -35,6 +35,7 @@ import com.intellij.ui.WindowMoveListener; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.ListWithFilter; import com.intellij.ui.speedSearch.NameFilteringListModel; import com.intellij.ui.speedSearch.SpeedSearch; @@ -55,10 +56,10 @@ import static com.intellij.ui.speedSearch.SpeedSearchSupply.ENTERED_PREFIX_PROPE public class RecentLocationsAction extends DumbAwareAction { private static final String RECENT_LOCATIONS_ACTION_ID = "RecentLocations"; private static final String LOCATION_SETTINGS_KEY = "recent.locations.popup"; - private static final int DEFAULT_WIDTH = JBUI.scale(700); - private static final int DEFAULT_HEIGHT = JBUI.scale(530); - private static final int MINIMUM_WIDTH = JBUI.scale(600); - private static final int MINIMUM_HEIGHT = JBUI.scale(450); + private static final int DEFAULT_WIDTH = JBUIScale.scale(700); + private static final int DEFAULT_HEIGHT = JBUIScale.scale(530); + private static final int MINIMUM_WIDTH = JBUIScale.scale(600); + private static final int MINIMUM_HEIGHT = JBUIScale.scale(450); private static final Color SHORTCUT_FOREGROUND_COLOR = UIUtil.getContextHelpForeground(); public static final String SHORTCUT_HEX_COLOR = String.format("#%02x%02x%02x", SHORTCUT_FOREGROUND_COLOR.getRed(), @@ -266,7 +267,7 @@ public class RecentLocationsAction extends DumbAwareAction { topPanel.add(checkbox, BorderLayout.EAST); Dimension size = topPanel.getPreferredSize(); - size.height = JBUI.scale(29); + size.height = JBUIScale.scale(29); topPanel.setPreferredSize(size); topPanel.setBorder(JBUI.Borders.empty(5, 8)); diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SwitchBootJdkAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SwitchBootJdkAction.java index 7cdd78f0b282..3cdcc77f18b4 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SwitchBootJdkAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SwitchBootJdkAction.java @@ -30,11 +30,11 @@ import com.intellij.ui.JBColor; import com.intellij.ui.SimpleListCellRenderer; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.panels.NonOpaquePanel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ArrayUtilRt; import com.intellij.util.JdkBundle; import com.intellij.util.JdkBundleList; import com.intellij.util.lang.JavaVersion; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; @@ -277,7 +277,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware { warningLabel.setIcon(UIUtil.getWarningIcon()); warningLabel.setForeground(JBColor.RED); - JPanel panel = new NonOpaquePanel(new BorderLayout(0, JBUI.scale(20))); + JPanel panel = new NonOpaquePanel(new BorderLayout(0, JBUIScale.scale(20))); panel.add(warningLabel, BorderLayout.NORTH); panel.add(new JBLabel("Select Boot JDK"), BorderLayout.CENTER); return panel; diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java index 799d30e552d6..d4185c3a682d 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java @@ -52,6 +52,7 @@ import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.popup.PopupUpdateProcessorBase; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.NameFilteringListModel; import com.intellij.ui.speedSearch.SpeedSearchUtil; import com.intellij.util.*; @@ -86,7 +87,7 @@ public class Switcher extends AnAction implements DumbAware { private static final Color SEPARATOR_COLOR = JBColor.namedColor("Popup.separatorColor", new JBColor(Gray.xC0, Gray.x4B)); private static final String TOGGLE_CHECK_BOX_ACTION_ID = "SwitcherRecentEditedChangedToggleCheckBox"; - private static final int MINIMUM_HEIGHT = JBUI.scale(100); + private static final int MINIMUM_HEIGHT = JBUIScale.scale(100); private static final Color ON_MOUSE_OVER_BG_COLOR = new JBColor(new Color(231, 242, 249), new Color(77, 80, 84)); @@ -734,8 +735,8 @@ public class Switcher extends AnAction implements DumbAware { topPanel.add(showOnlyEditedFilesCheckBox, BorderLayout.EAST); Dimension size = topPanel.getPreferredSize(); - size.height = JBUI.scale(29); - size.width = titleLabel.getPreferredSize().width + showOnlyEditedFilesCheckBox.getPreferredSize().width + JBUI.scale(50); + size.height = JBUIScale.scale(29); + size.width = titleLabel.getPreferredSize().width + showOnlyEditedFilesCheckBox.getPreferredSize().width + JBUIScale.scale(50); topPanel.setPreferredSize(size); topPanel.setMinimumSize(size); topPanel.setBorder(JBUI.Borders.empty(5, 8)); @@ -1278,7 +1279,7 @@ public class Switcher extends AnAction implements DumbAware { @Override public void layoutContainer(@NotNull Container target) { - final JScrollPane scrollPane = UIUtil.getParentOfType(JScrollPane.class, files); + final JScrollPane scrollPane = ComponentUtil.getParentOfType((Class)JScrollPane.class, (Component)files); JComponent filesPane = scrollPane != null ? scrollPane : files; if (sBounds == null || !target.isShowing()) { super.layoutContainer(target); diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java index 79bcb3d75773..2b0002cb1a39 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.actions; import com.intellij.openapi.ui.GraphicsConfig; @@ -7,9 +7,9 @@ import com.intellij.openapi.wm.ToolWindow; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.SpeedSearchBase; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.IconUtil; import com.intellij.util.PlatformIcons; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -75,7 +75,7 @@ class SwitcherToolWindowsListRenderer extends ColoredListCellRenderer ourSavedValues = new LinkedHashMap<>(); - private static float ourSavedScaleFactor = JBUI.scale(1f); + private static float ourSavedScaleFactor = JBUIScale.scale(1f); private static int ourSavedConsoleFontSize; @Override @@ -132,17 +132,17 @@ public class TogglePresentationModeAction extends AnAction implements DumbAware } } } - float scaleFactor = JBUI.getFontScale(settings.getPresentationModeFontSize()); - ourSavedScaleFactor = JBUI.scale(1f); - JBUI.setUserScaleFactor(scaleFactor); + float scaleFactor = JBUIScale.getFontScale(settings.getPresentationModeFontSize()); + ourSavedScaleFactor = JBUIScale.scale(1f); + JBUIScale.setUserScaleFactor(scaleFactor); for (Object key : ourSavedValues.keySet()) { Object v = ourSavedValues.get(key); if (v instanceof Font) { Font font = (Font)v; - defaults.put(key, new FontUIResource(font.getName(), font.getStyle(), JBUI.scale(font.getSize()))); + defaults.put(key, new FontUIResource(font.getName(), font.getStyle(), JBUIScale.scale(font.getSize()))); } else if (v instanceof Integer) { - defaults.put(key, JBUI.scale(((Integer)v).intValue())); + defaults.put(key, JBUIScale.scale(((Integer)v).intValue())); } } } @@ -150,7 +150,7 @@ public class TogglePresentationModeAction extends AnAction implements DumbAware for (Object key : ourSavedValues.keySet()) { defaults.put(key, ourSavedValues.get(key)); } - JBUI.setUserScaleFactor(ourSavedScaleFactor); + JBUIScale.setUserScaleFactor(ourSavedScaleFactor); ourSavedValues.clear(); } } diff --git a/platform/platform-impl/src/com/intellij/ide/gdpr/ConsentSettingsUi.java b/platform/platform-impl/src/com/intellij/ide/gdpr/ConsentSettingsUi.java index 4482c562c1d4..56846b616634 100644 --- a/platform/platform-impl/src/com/intellij/ide/gdpr/ConsentSettingsUi.java +++ b/platform/platform-impl/src/com/intellij/ide/gdpr/ConsentSettingsUi.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.gdpr; import com.intellij.ide.BrowserUtil; @@ -13,6 +13,7 @@ import com.intellij.ui.JBColor; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.SwingHelper; import com.intellij.util.ui.UI; @@ -91,13 +92,13 @@ public class ConsentSettingsUi extends JPanel implements ConfigurableUi"; + return "

"; } @NotNull @@ -139,11 +140,11 @@ public class ConsentSettingsUi extends JPanel implements ConfigurableUi)field -> field.getText().isEmpty()); editor.setBorder(JBUI.Borders.empty(0, 6)); editor.setOpaque(true); @@ -1699,7 +1700,7 @@ public class PluginManagerConfigurableNew } public static int offset5() { - return JBUI.scale(5); + return JBUIScale.scale(5); } public static boolean isJBPlugin(@NotNull IdeaPluginDescriptor plugin) { diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableNewLayout.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableNewLayout.java index fcef817e747f..26a20ddfcb36 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableNewLayout.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableNewLayout.java @@ -36,13 +36,11 @@ import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; import com.intellij.ui.popup.PopupFactoryImpl; import com.intellij.ui.popup.list.PopupListElementRenderer; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Url; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.net.HttpConfigurable; -import com.intellij.util.ui.JBDimension; -import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.StatusText; -import com.intellij.util.ui.UIUtil; +import com.intellij.util.ui.*; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -278,7 +276,7 @@ public class PluginManagerConfigurableNewLayout @Override protected Border getDefaultItemComponentBorder() { - return new EmptyBorder(JBUI.insets(UIUtil.getListCellVPadding(), 15)); + return new EmptyBorder(JBInsets.create(UIUtil.getListCellVPadding(), 15)); } }; } @@ -544,7 +542,7 @@ public class PluginManagerConfigurableNewLayout } }); // TODO: icon myMarketplaceSortByAction.setPaintUnderline(false); - myMarketplaceSortByAction.setIconTextGap(JBUI.scale(4)); + myMarketplaceSortByAction.setIconTextGap(JBUIScale.scale(4)); myMarketplaceSortByAction.setHorizontalTextPosition(SwingConstants.LEFT); myMarketplaceSortByAction.setForeground(PluginsGroupComponent.SECTION_HEADER_FOREGROUND); diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableTreeRenderer.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableTreeRenderer.java index d33ab8eab0ed..c06cb2042537 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableTreeRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurableTreeRenderer.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.plugins; import com.intellij.ide.plugins.newui.PluginUpdatesService; @@ -8,8 +8,8 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.AncestorListenerAdapter; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.treeStructure.SimpleTree; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,7 +43,7 @@ public class PluginManagerConfigurableTreeRenderer extends AncestorListenerAdapt return Pair.create(myCountLabel, (renderer, bounds, text, right, textBaseline) -> { Dimension size = renderer.getPreferredSize(); - int x = right.x - JBUI.scale(2) + (right.width - size.width) / 2; + int x = right.x - JBUIScale.scale(2) + (right.width - size.width) / 2; int y = bounds.y + textBaseline - renderer.getBaseline(size.width, size.height); renderer.setBounds(x, y, size.width, size.height); }); diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java index 3dfd7c09acc9..402403b7300b 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java @@ -36,6 +36,7 @@ import com.intellij.ui.*; import com.intellij.ui.border.CustomLineBorder; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.SpeedSearchSupply; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; @@ -224,9 +225,9 @@ public abstract class PluginManagerMain implements Disposable { } private static String getTextPrefix() { - int fontSize = JBUI.scale(12); - int m1 = JBUI.scale(2); - int m2 = JBUI.scale(5); + int fontSize = JBUIScale.scale(12); + int m1 = JBUIScale.scale(2); + int m2 = JBUIScale.scale(5); return String.format( "" + " ").toString(); } - @Deprecated - public static boolean isWinLafOnVista() { - return SystemInfo.isWinVistaOrNewer && "Windows".equals(UIManager.getLookAndFeel().getName()); - } - - @Deprecated - public static boolean isStandardMenuLAF() { - return isWinLafOnVista() || - isUnderGTKLookAndFeel(); - } - @NotNull public static Color getFocusedFillColor() { return toAlpha(getListSelectionBackground(), 100); @@ -2371,14 +2188,8 @@ public class UIUtil extends StartupUiUtil { } @Nullable - public static Component findUltimateParent(Component c) { - if (c == null) return null; - - Component eachParent = c; - while (true) { - if (eachParent.getParent() == null) return eachParent; - eachParent = eachParent.getParent(); - } + public static Component findUltimateParent(@Nullable Component c) { + return c == null ? null : ComponentUtil.findUltimateParent(c); } @NotNull @@ -2463,7 +2274,7 @@ public class UIUtil extends StartupUiUtil { return new JBHtmlEditorKit(noGapsBetweenParagraphs); } - public static class JBWordWrapHtmlEditorKit extends JBHtmlEditorKit { + public static final class JBWordWrapHtmlEditorKit extends JBHtmlEditorKit { private final HTMLFactory myFactory = new HTMLFactory() { @Override public View create(Element e) { @@ -2550,7 +2361,7 @@ public class UIUtil extends StartupUiUtil { html = CLOSE_TAG_PATTERN.matcher(html).replaceAll("<$1$2>"); Font font = getLabelFont(); @NonNls String family = font != null ? font.getFamily() : "Tahoma"; - int size = font != null ? font.getSize() : JBUI.scale(11); + int size = font != null ? font.getSize() : JBUIScale.scale(11); return "" @@ -2595,11 +2406,12 @@ public class UIUtil extends StartupUiUtil { * On AWT thread, invoked runnable immediately, otherwise do {@link SwingUtilities#invokeLater(Runnable)} on it. */ public static void invokeLaterIfNeeded(@NotNull Runnable runnable) { - if (EdtInvocationManager.getInstance().isEventDispatchThread()) { + EdtInvocationManager edtInvocationManager = EdtInvocationManager.getInstance(); + if (edtInvocationManager.isEventDispatchThread()) { runnable.run(); } else { - EdtInvocationManager.getInstance().invokeLater(runnable); + edtInvocationManager.invokeLater(runnable); } } @@ -2715,50 +2527,6 @@ public class UIUtil extends StartupUiUtil { ); } - public static void installComboBoxCopyAction(@NotNull JComboBox comboBox) { - final ComboBoxEditor editor = comboBox.getEditor(); - final Component editorComponent = editor != null ? editor.getEditorComponent() : null; - if (!(editorComponent instanceof JTextComponent)) return; - final InputMap inputMap = ((JTextComponent)editorComponent).getInputMap(); - for (KeyStroke keyStroke : inputMap.allKeys()) { - if (DefaultEditorKit.copyAction.equals(inputMap.get(keyStroke))) { - comboBox.getInputMap().put(keyStroke, DefaultEditorKit.copyAction); - } - } - comboBox.getActionMap().put(DefaultEditorKit.copyAction, new AbstractAction() { - @Override - public void actionPerformed(final ActionEvent e) { - if (!(e.getSource() instanceof JComboBox)) return; - final JComboBox comboBox = (JComboBox)e.getSource(); - final String text; - final Object selectedItem = comboBox.getSelectedItem(); - if (selectedItem instanceof String) { - text = (String)selectedItem; - } - else { - final Component component = - comboBox.getRenderer().getListCellRendererComponent(new JList(), selectedItem, 0, false, false); - if (component instanceof JLabel) { - text = ((JLabel)component).getText(); - } - else if (component != null) { - final String str = component.toString(); - // skip default Component.toString and handle SimpleColoredComponent case - text = str == null || str.startsWith(component.getClass().getName() + "[") ? null : str; - } - else { - text = null; - } - } - if (text != null) { - final JTextField textField = new JTextField(text); - textField.selectAll(); - textField.copy(); - } - } - }); - } - @Nullable public static ComboPopup getComboBoxPopup(@NotNull JComboBox comboBox) { final ComboBoxUI ui = comboBox.getUI(); @@ -2866,14 +2634,7 @@ public class UIUtil extends StartupUiUtil { @Nullable @Contract(pure = true) public static T getParentOfType(@NotNull Class type, Component component) { - while (component != null) { - if (type.isInstance(component)) { - //noinspection unchecked - return (T)component; - } - component = component.getParent(); - } - return null; + return ComponentUtil.getParentOfType(type, component); } @NotNull @@ -3186,7 +2947,7 @@ public class UIUtil extends StartupUiUtil { @Nullable public static JRootPane getRootPane(Component c) { - JRootPane root = getParentOfType(JRootPane.class, c); + JRootPane root = ComponentUtil.getParentOfType((Class)JRootPane.class, c); if (root != null) return root; Component eachParent = c; while (eachParent != null) { @@ -3220,6 +2981,7 @@ public class UIUtil extends StartupUiUtil { } }; } + @NotNull public static Timer createNamedTimer(@NonNls @NotNull final String name, int delay) { return new Timer(delay, null) { @@ -3596,8 +3358,7 @@ public class UIUtil extends StartupUiUtil { */ @Nullable public static Window getWindow(@Nullable Component component) { - return component == null ? null : - component instanceof Window ? (Window)component : SwingUtilities.getWindowAncestor(component); + return ComponentUtil.getWindow(component); } /** @@ -3747,7 +3508,7 @@ public class UIUtil extends StartupUiUtil { } public static boolean isRetina(@NotNull GraphicsDevice device) { - return UIUtil.DetectRetinaKit.isOracleMacRetinaDevice(device); + return DetectRetinaKit.isOracleMacRetinaDevice(device); } /** Employs a common pattern to use {@code Graphics}. This is a non-distractive approach @@ -3989,4 +3750,14 @@ public class UIUtil extends StartupUiUtil { public static Color getTableSelectionForeground() { return UIManager.getColor("Table.selectionForeground"); } + + @Deprecated + public static Pair getSystemFontData() { + return JBUIScale.getSystemFontData(); + } + + @Deprecated + public static boolean isJreHiDPIEnabled() { + return JreHiDpiUtil.isJreHiDPIEnabled(); + } } diff --git a/platform/util/ui/src/com/intellij/util/ui/components/BorderLayoutPanel.java b/platform/util/ui/src/com/intellij/util/ui/components/BorderLayoutPanel.java index 582a50d5d5e3..2f843b4fe56f 100644 --- a/platform/util/ui/src/com/intellij/util/ui/components/BorderLayoutPanel.java +++ b/platform/util/ui/src/com/intellij/util/ui/components/BorderLayoutPanel.java @@ -2,7 +2,7 @@ package com.intellij.util.ui.components; import com.intellij.ui.components.JBPanel; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.accessibility.AccessibleContextDelegate; import org.jetbrains.annotations.NotNull; @@ -21,7 +21,7 @@ public class BorderLayoutPanel extends JBPanel { } public BorderLayoutPanel(int hgap, int vgap) { - super(new BorderLayout(JBUI.scale(hgap), JBUI.scale(vgap))); + super(new BorderLayout(JBUIScale.scale(hgap), JBUIScale.scale(vgap))); } @NotNull diff --git a/platform/util/ui/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java b/platform/util/ui/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java index 03c37f91c240..d2a37a00e720 100644 --- a/platform/util/ui/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java +++ b/platform/util/ui/src/com/intellij/util/ui/tree/WideSelectionTreeUI.java @@ -5,7 +5,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Conditions; import com.intellij.openapi.util.registry.Registry; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.MouseEventAdapter; import com.intellij.util.ui.StartupUiUtil; import com.intellij.util.ui.UIUtil; @@ -131,7 +131,7 @@ public class WideSelectionTreeUI extends BasicTreeUI { } protected int getCustomIndent() { - return JBUI.scale(Registry.intValue("ide.ui.tree.indent")); + return JBUIScale.scale(Registry.intValue("ide.ui.tree.indent")); } @Override diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java index 9f7341125758..6024c758cb57 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java @@ -34,6 +34,7 @@ import com.intellij.openapi.vcs.changes.LocalChangeList; import com.intellij.openapi.vcs.ex.*; import com.intellij.openapi.vcs.impl.LineStatusTrackerManager; import com.intellij.ui.InplaceButton; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; @@ -528,7 +529,7 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { Dimension size = myCheckbox.getPreferredSize(); EditorGutterComponentEx gutter = getEditor2().getGutterComponentEx(); int gutterWidth = gutter.getLineMarkerFreePaintersAreaOffset(); - return new Dimension(Math.max(gutterWidth + JBUI.scale(2), size.width), size.height); + return new Dimension(Math.max(gutterWidth + JBUIScale.scale(2), size.width), size.height); } private void updateLayout() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchMergeTool.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchMergeTool.java index f6e04019d726..331e503b5996 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchMergeTool.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/tool/ApplyPatchMergeTool.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs.changes.patch.tool; import com.intellij.diff.DiffContext; @@ -22,8 +8,8 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diff.DiffBundle; import com.intellij.openapi.ui.Messages; import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -119,7 +105,7 @@ public class ApplyPatchMergeTool implements MergeTool { if (isDisposed()) return; JComponent component = getComponent(); - int yOffset = new RelativePoint(getResultEditor().getComponent(), new Point(0, JBUI.scale(5))).getPoint(component).y; + int yOffset = new RelativePoint(getResultEditor().getComponent(), new Point(0, JBUIScale.scale(5))).getPoint(component).y; RelativePoint point = new RelativePoint(component, new Point(component.getWidth() / 2, yOffset)); String message = DiffBundle.message("apply.patch.all.changes.processed.message.text"); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java index b92332f29412..31ada35eaffa 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangeListChooserPanel.java @@ -12,6 +12,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vcs.changes.*; import com.intellij.ui.*; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.NullableConsumer; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.JBUI; @@ -215,9 +216,9 @@ public class ChangeListChooserPanel extends JPanel { super(PREF_WIDTH); JBColor fg = new JBColor(0x00b53d, 0x6ba65d); JBColor bg = new JBColor(0xebfcf1, 0x313b32); - TextIcon icon = new TextIcon("New", fg, bg, JBUI.scale(2)); + TextIcon icon = new TextIcon("New", fg, bg, JBUIScale.scale(2)); icon.setFont(RelativeFont.TINY.derive(getFont())); - icon.setRound(JBUI.scale(4)); + icon.setRound(JBUIScale.scale(4)); JLabel label = new JLabel(icon); JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(true); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 6e8ac66f61cc..5846e1b91bf9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -29,6 +29,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.JBColor; import com.intellij.ui.SplitterWithSecondHideable; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Alarm; import com.intellij.util.EventDispatcher; import com.intellij.util.containers.ContainerUtil; @@ -237,7 +238,7 @@ public abstract class CommitChangeListDialog extends DialogWrapper implements Si myCommitOptions = new CommitOptionsPanel(() -> getDefaultCommitActionName()); myWarningLabel = new JBLabel(); - JPanel mainPanel = new JPanel(new MyOptionsLayout(mySplitter, myCommitOptions, JBUI.scale(150), JBUI.scale(400))); + JPanel mainPanel = new JPanel(new MyOptionsLayout(mySplitter, myCommitOptions, JBUIScale.scale(150), JBUIScale.scale(400))); mainPanel.add(mySplitter); mainPanel.add(myCommitOptions); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/CommitPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/CommitPanel.java index 2bfb014ca241..e1242d9b7c37 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/CommitPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/CommitPanel.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.vcs.log.ui.frame; import com.intellij.ide.IdeTooltipManager; @@ -12,6 +12,7 @@ import com.intellij.ui.BrowserHyperlinkListener; import com.intellij.ui.JBColor; import com.intellij.ui.components.JBPanel; import com.intellij.ui.components.panels.Wrapper; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ColorIcon; @@ -293,7 +294,7 @@ public class CommitPanel extends JBPanel { public Dimension getPreferredSize() { if (myIcon == null) return new Dimension(0, 0); Dimension size = super.getPreferredSize(); - return new Dimension(myIcon.getIconWidth() + JBUI.scale(ROOT_GAP), size.height); + return new Dimension(myIcon.getIconWidth() + JBUIScale.scale(ROOT_GAP), size.height); } public void setRoot(@NotNull VirtualFile root) { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index a719aefd06df..a901765b0417 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -26,6 +26,7 @@ import com.intellij.ui.SeparatorComponent; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBLoadingPanel; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.JBUI; @@ -252,7 +253,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos @Override public Dimension getMinimumSize() { Dimension minimumSize = super.getMinimumSize(); - return new Dimension(Math.max(minimumSize.width, JBUI.scale(MIN_SIZE)), Math.max(minimumSize.height, JBUI.scale(MIN_SIZE))); + return new Dimension(Math.max(minimumSize.width, JBUIScale.scale(MIN_SIZE)), Math.max(minimumSize.height, JBUIScale.scale(MIN_SIZE))); } @Override diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ProgressStripeIcon.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ProgressStripeIcon.java index b787bccb723f..0418cde9b75b 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ProgressStripeIcon.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ProgressStripeIcon.java @@ -4,9 +4,9 @@ package com.intellij.vcs.log.ui.frame; import com.intellij.ide.ui.laf.intellij.MacIntelliJProgressBarUI; import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.JBColor; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.AsyncProcessIcon; import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -69,22 +69,22 @@ public abstract class ProgressStripeIcon implements Icon { @Override public int getChunkWidth() { - return 2 * JBUI.scale(GRADIENT); + return 2 * JBUIScale.scale(GRADIENT); } @Override public void paint(@NotNull Graphics2D g2, int x, int y, int shift) { Color dark = DARK; Color light = LIGHT; - g2.setPaint(new GradientPaint(x + shift, y, dark, x + shift + JBUI.scale(GRADIENT), y, light)); - g2.fill(new Rectangle(x + shift, y, JBUI.scale(GRADIENT), getIconHeight())); - g2.setPaint(new GradientPaint(x + shift + JBUI.scale(GRADIENT), y, light, x + shift + 2 * JBUI.scale(GRADIENT), y, dark)); - g2.fill(new Rectangle(x + shift + JBUI.scale(GRADIENT), y, JBUI.scale(GRADIENT), getIconHeight())); + g2.setPaint(new GradientPaint(x + shift, y, dark, x + shift + JBUIScale.scale(GRADIENT), y, light)); + g2.fill(new Rectangle(x + shift, y, JBUIScale.scale(GRADIENT), getIconHeight())); + g2.setPaint(new GradientPaint(x + shift + JBUIScale.scale(GRADIENT), y, light, x + shift + 2 * JBUIScale.scale(GRADIENT), y, dark)); + g2.fill(new Rectangle(x + shift + JBUIScale.scale(GRADIENT), y, JBUIScale.scale(GRADIENT), getIconHeight())); } @Override public int getIconHeight() { - return JBUI.scale(GRADIENT_HEIGHT); + return JBUIScale.scale(GRADIENT_HEIGHT); } private static class ProgressStripeColor extends JBColor { @@ -102,7 +102,7 @@ public abstract class ProgressStripeIcon implements Icon { @NotNull public static AsyncProcessIcon generateIcon(@NotNull JComponent component) { List result = new ArrayList<>(); - for (int i = 0; i < 2 * JBUI.scale(GradientIcon.GRADIENT); i += JBUI.scale(TRANSLATE)) { + for (int i = 0; i < 2 * JBUIScale.scale(GradientIcon.GRADIENT); i += JBUIScale.scale(TRANSLATE)) { result.add(new GradientIcon(component, i)); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java index 886ea602721d..cc45b0e78c6d 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/ReferencesPanel.java @@ -1,27 +1,13 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.vcs.log.ui.frame; import com.intellij.openapi.vcs.ui.FontUtil; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.panels.Wrapper; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; -import com.intellij.util.ui.JBUI; import com.intellij.vcs.log.VcsRef; import com.intellij.vcs.log.VcsRefType; import com.intellij.vcs.log.ui.render.LabelIcon; @@ -46,7 +32,7 @@ public class ReferencesPanel extends JPanel { @NotNull protected MultiMap myGroupedVisibleReferences; public ReferencesPanel() { - this(new WrappedFlowLayout(JBUI.scale(H_GAP), JBUI.scale(V_GAP)), -1); + this(new WrappedFlowLayout(JBUIScale.scale(H_GAP), JBUIScale.scale(V_GAP)), -1); } public ReferencesPanel(LayoutManager layout, int limit) { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java index 8bf16478bee7..98064ad093ed 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/GraphCommitCellRenderer.java @@ -1,3 +1,4 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.vcs.log.ui.render; import com.intellij.openapi.util.text.StringUtil; @@ -7,9 +8,9 @@ import com.intellij.ui.SimpleColoredRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.paint.PaintUtil; import com.intellij.ui.paint.PaintUtil.RoundingMode; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.SpeedSearchUtil; import com.intellij.util.ObjectUtils; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.VcsRef; import com.intellij.vcs.log.data.VcsLogData; @@ -31,7 +32,7 @@ import java.util.Objects; public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer { private static final int MAX_GRAPH_WIDTH = 6; - private static final int VERTICAL_PADDING = JBUI.scale(7); + private static final int VERTICAL_PADDING = JBUIScale.scale(7); @NotNull private final VcsLogData myLogData; @NotNull private final VcsLogGraphTable myGraphTable; @@ -242,7 +243,7 @@ public class GraphCommitCellRenderer extends TypeSafeTableCellRenderer(40, 20) fun getIcon(component: JComponent, height: Int, bgColor: Color, colors: List): LabelIcon { - val id = LabelIconId(JBUI.sysScale(component.graphicsConfiguration), height, bgColor, colors) + val id = LabelIconId(JBUIScale.sysScale(component.graphicsConfiguration), height, bgColor, colors) var icon = cache.get(id) if (icon == null) { icon = LabelIcon(component, height, bgColor, colors) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java index 1654c9e4ba3d..2a99f9f5d3b9 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java @@ -9,10 +9,10 @@ import com.intellij.openapi.vcs.changes.ui.CurrentBranchComponent; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.JBColor; import com.intellij.ui.SimpleColoredComponent; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.JBValue; import com.intellij.util.ui.JBValue.JBValueGroup; import com.intellij.util.ui.UIUtil; @@ -51,7 +51,7 @@ public class LabelPainter { @NotNull private final LabelIconCache myIconCache; @NotNull private List> myLabels = new ArrayList<>(); - private int myHeight = JBUI.scale(22); + private int myHeight = JBUIScale.scale(22); private int myWidth = 0; @NotNull private Color myBackground = UIUtil.getTableBackground(); @Nullable private Color myGreyBackground = null; diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/TooltipReferencesPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/TooltipReferencesPanel.java index cdb37a1702d4..cd45f05b8610 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/TooltipReferencesPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/TooltipReferencesPanel.java @@ -1,28 +1,14 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.vcs.log.ui.render; import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ColorUtil; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.EmptyIcon; -import com.intellij.util.ui.JBUI; import com.intellij.vcs.log.VcsRef; import com.intellij.vcs.log.VcsRefType; import com.intellij.vcs.log.data.VcsLogData; @@ -41,7 +27,7 @@ class TooltipReferencesPanel extends ReferencesPanel { private boolean myHasGroupWithMultipleRefs; TooltipReferencesPanel(@NotNull VcsLogData logData, @NotNull Collection refs) { - super(new VerticalFlowLayout(JBUI.scale(H_GAP), JBUI.scale(V_GAP)), REFS_LIMIT); + super(new VerticalFlowLayout(JBUIScale.scale(H_GAP), JBUIScale.scale(V_GAP)), REFS_LIMIT); VirtualFile root = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(refs)).getRoot(); setReferences(ContainerUtil.sorted(refs, logData.getLogProvider(root).getReferenceManager().getLabelsOrderComparator())); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/GraphTableController.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/GraphTableController.java index 5f76fce3495d..4bf7885de12e 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/GraphTableController.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/GraphTableController.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.vcs.log.ui.table; import com.intellij.ide.IdeTooltip; @@ -21,9 +7,9 @@ import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.vcs.changes.issueLinks.TableLinkMouseListener; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.components.panels.Wrapper; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ArrayUtil; import com.intellij.util.ObjectUtils; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.CommitId; import com.intellij.vcs.log.VcsShortCommitDetails; @@ -275,7 +261,7 @@ public class GraphTableController { // user may have clicked just outside of the border // in that case, c is not the column we are looking for int c2 = - myTable.columnAtPoint(new Point(e.getPoint().x + (useLeftBorder ? 1 : -1) * JBUI.scale(BORDER_THICKNESS), e.getPoint().y)); + myTable.columnAtPoint(new Point(e.getPoint().x + (useLeftBorder ? 1 : -1) * JBUIScale.scale(BORDER_THICKNESS), e.getPoint().y)); int column2 = myTable.convertColumnIndexToModel(c2); if ((useLeftBorder ? isOnLeftBorder(e, c2) : isOnRightBorder(e, c2)) && ArrayUtil.indexOf(DYNAMIC_COLUMNS, column) != -1) { @@ -299,12 +285,12 @@ public class GraphTableController { } public boolean isOnLeftBorder(@NotNull MouseEvent e, int column) { - return Math.abs(getColumnLeftXCoordinate(column) - e.getPoint().x) <= JBUI.scale(BORDER_THICKNESS); + return Math.abs(getColumnLeftXCoordinate(column) - e.getPoint().x) <= JBUIScale.scale(BORDER_THICKNESS); } public boolean isOnRightBorder(@NotNull MouseEvent e, int column) { return Math.abs(getColumnLeftXCoordinate(column) + - myTable.getColumnModel().getColumn(column).getWidth() - e.getPoint().x) <= JBUI.scale(BORDER_THICKNESS); + myTable.getColumnModel().getColumn(column).getWidth() - e.getPoint().x) <= JBUIScale.scale(BORDER_THICKNESS); } @Override diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java index ca0af86f97e1..4f2aa4cbb25b 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java @@ -1,24 +1,10 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.vcs.log.ui.table; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ScrollingUtil; import com.intellij.ui.SimpleColoredRenderer; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.UIUtil; import com.intellij.vcs.log.impl.VcsLogUiProperties; import com.intellij.vcs.log.ui.VcsLogColorManager; @@ -48,10 +34,10 @@ class RootCellRenderer extends SimpleColoredRenderer implements TableCellRendere g.setColor(myColor); if (isNarrow) { - g.fillRect(x, 0, width - JBUI.scale(VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH), height); + g.fillRect(x, 0, width - JBUIScale.scale(VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH), height); g.setColor(myBorderColor); - g.fillRect(x + width - JBUI.scale(VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH), 0, - JBUI.scale(VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH), + g.fillRect(x + width - JBUIScale.scale(VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH), 0, + JBUIScale.scale(VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH), height); } else { diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/VcsLogGraphTable.java index 9f8aafcfef48..f43d9fc3ce10 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/VcsLogGraphTable.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/VcsLogGraphTable.java @@ -15,10 +15,8 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsDataKeys; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.ui.ColoredTableCellRenderer; -import com.intellij.ui.JBColor; -import com.intellij.ui.ScrollingUtil; -import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.*; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.SpeedSearchUtil; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; @@ -340,7 +338,8 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider, maxAuthorWidth = Math.max(getFontMetrics(font).stringWidth(value + "*"), maxAuthorWidth); } - int width = Math.min(maxAuthorWidth + myStringCellRenderer.getHorizontalTextPadding(), JBUI.scale(MAX_DEFAULT_AUTHOR_COLUMN_WIDTH)); + int width = Math.min(maxAuthorWidth + myStringCellRenderer.getHorizontalTextPadding(), + JBUIScale.scale(MAX_DEFAULT_AUTHOR_COLUMN_WIDTH)); if (unloaded * 2 <= maxRowsToCheck) myAuthorColumnInitialized = true; return width; } @@ -402,7 +401,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider, rootWidth = 0; } else if (!isShowRootNames()) { - rootWidth = JBUI.scale(ROOT_INDICATOR_WIDTH); + rootWidth = JBUIScale.scale(ROOT_INDICATOR_WIDTH); } else { int width = 0; @@ -410,7 +409,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider, Font tableFont = getTableFont(); width = Math.max(getFontMetrics(tableFont).stringWidth(file.getName() + " "), width); } - rootWidth = Math.min(width, JBUI.scale(ROOT_NAME_MAX_WIDTH)); + rootWidth = Math.min(width, JBUIScale.scale(ROOT_NAME_MAX_WIDTH)); } // NB: all further instructions and their order are important, otherwise the minimum size which is less than 15 won't be applied @@ -606,7 +605,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider, @Override public void setCursor(Cursor cursor) { super.setCursor(cursor); - Component layeredPane = UIUtil.findParentByCondition(this, component -> component instanceof LoadingDecorator.CursorAware); + Component layeredPane = ComponentUtil.findParentByCondition(this, component -> component instanceof LoadingDecorator.CursorAware); if (layeredPane != null) { layeredPane.setCursor(cursor); } @@ -669,7 +668,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider, g.setColor(getRootBackgroundColor(getModel().getRoot(lastRow), myColorManager)); int rootWidth = getRootColumn().getWidth(); - if (!isShowRootNames()) rootWidth -= JBUI.scale(ROOT_INDICATOR_WHITE_WIDTH); + if (!isShowRootNames()) rootWidth -= JBUIScale.scale(ROOT_INDICATOR_WHITE_WIDTH); g.fillRect(x, y, rootWidth, height); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerInlayUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerInlayUtil.java index c67609c758db..1008f2db7721 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerInlayUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerInlayUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.xdebugger.impl; import com.intellij.openapi.editor.Editor; @@ -32,8 +18,8 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.DocumentUtil; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl; @@ -154,7 +140,7 @@ public class XDebuggerInlayUtil { int curX = 0; for (ValueInfo value : values) { - curX += JBUI.scale(5); // minimum gap between values + curX += JBUIScale.scale(5); // minimum gap between values int xStart = editor.offsetToXY(value.refStartOffset, true, false).x; int xEnd = editor.offsetToXY(value.refEndOffset, false, true).x; int width = g.getFontMetrics().stringWidth(value.value); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java index 351f5a0e923c..26d59dde45bb 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.xdebugger.impl.breakpoints.ui; import com.intellij.icons.AllIcons; @@ -20,7 +20,6 @@ import com.intellij.ui.popup.util.MasterController; import com.intellij.util.SingleAlarm; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.XDebuggerManager; @@ -321,7 +320,7 @@ public class BreakpointsDialog extends DialogWrapper { JPanel decoratedTree = decorator.createPanel(); decoratedTree.setBorder(JBUI.Borders.empty()); - JScrollPane pane = UIUtil.getParentOfType(JScrollPane.class, tree); + JScrollPane pane = ComponentUtil.getParentOfType((Class)JScrollPane.class, (Component)tree); if (pane != null) pane.setBorder(IdeBorderFactory.createBorder()); myTreeController.setTreeView(tree); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java index 1b93beb035cf..265578e4df61 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.xdebugger.impl.ui; import com.intellij.codeInsight.lookup.LookupManager; @@ -24,8 +10,8 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; +import com.intellij.ui.ComponentUtil; import com.intellij.ui.components.labels.LinkLabel; -import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.impl.actions.XDebuggerActions; import org.jetbrains.annotations.NotNull; @@ -86,7 +72,7 @@ public class BreakpointEditor { (editor != null && TemplateManager.getInstance(project).getActiveTemplate(editor) != null)); final Component owner = IdeFocusManager.findInstance().getFocusOwner(); if (owner != null) { - final JComboBox comboBox = UIUtil.getParentOfType(JComboBox.class, owner); + final JComboBox comboBox = ComponentUtil.getParentOfType((Class)JComboBox.class, owner); if (comboBox != null && comboBox.isPopupVisible()) { disabled = true; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesTable.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesTable.java index 8a96bc603725..0ca6e10a4bf8 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesTable.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesTable.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.xdebugger.memory.ui; import com.intellij.icons.AllIcons; @@ -12,11 +12,11 @@ import com.intellij.psi.codeStyle.NameUtil; import com.intellij.ui.ColoredTableCellRenderer; import com.intellij.ui.JBColor; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.scale.JBUIScale; import com.intellij.ui.speedSearch.SpeedSearchUtil; import com.intellij.ui.table.JBTable; import com.intellij.util.containers.FList; import com.intellij.util.ui.JBDimension; -import com.intellij.util.ui.JBUI; import com.intellij.xdebugger.memory.component.InstancesTracker; import com.intellij.xdebugger.memory.tracking.TrackerForNewInstancesBase; import com.intellij.xdebugger.memory.tracking.TrackingType; @@ -36,8 +36,8 @@ import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.util.*; import java.util.List; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; public class ClassesTable extends JBTable implements DataProvider, Disposable { @@ -131,11 +131,11 @@ public class ClassesTable extends JBTable implements DataProvider, Disposable { TableColumn diffColumn = columnModel.getColumn(DiffViewTableModel.DIFF_COLUMN_INDEX); setAutoResizeMode(AUTO_RESIZE_SUBSEQUENT_COLUMNS); - classesColumn.setPreferredWidth(JBUI.scale(CLASSES_COLUMN_PREFERRED_WIDTH)); + classesColumn.setPreferredWidth(JBUIScale.scale(CLASSES_COLUMN_PREFERRED_WIDTH)); - countColumn.setMinWidth(JBUI.scale(COUNT_COLUMN_MIN_WIDTH)); + countColumn.setMinWidth(JBUIScale.scale(COUNT_COLUMN_MIN_WIDTH)); - diffColumn.setMinWidth(JBUI.scale(DIFF_COLUMN_MIN_WIDTH)); + diffColumn.setMinWidth(JBUIScale.scale(DIFF_COLUMN_MIN_WIDTH)); TableRowSorter sorter = new TableRowSorter<>(myModel); sorter.setRowFilter(new RowFilter() { diff --git a/plugins/ant/src/com/intellij/lang/ant/validation/AntHectorConfigurable.java b/plugins/ant/src/com/intellij/lang/ant/validation/AntHectorConfigurable.java index ff979e167d36..1f4701486213 100644 --- a/plugins/ant/src/com/intellij/lang/ant/validation/AntHectorConfigurable.java +++ b/plugins/ant/src/com/intellij/lang/ant/validation/AntHectorConfigurable.java @@ -1,18 +1,4 @@ -/* - * 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. - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.ant.validation; import com.intellij.lang.ant.AntImportsIndex; @@ -30,6 +16,7 @@ import com.intellij.psi.xml.XmlFile; import com.intellij.ui.IdeBorderFactory; import com.intellij.util.PathUtil; import com.intellij.util.indexing.FileBasedIndex; +import com.intellij.util.ui.JBInsets; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NonNls; @@ -77,7 +64,7 @@ public class AntHectorConfigurable extends HectorComponentPanel { myCombo.putClientProperty(CONTEXTS_COMBO_KEY, Boolean.TRUE); panel.add( new JLabel("Included into:"), - new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(5, 0), 0, 0) + new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBInsets.create(5, 0), 0, 0) ); panel.add( myCombo, diff --git a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java index 64a78f0a2a52..8fe752c88fcc 100644 --- a/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java +++ b/plugins/coverage-common/src/com/intellij/coverage/view/CoverageViewManager.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.coverage.view; import com.intellij.coverage.CoverageDataManager; @@ -16,7 +16,7 @@ import com.intellij.openapi.wm.ToolWindowAnchor; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import org.jetbrains.annotations.NotNull; import java.util.HashMap; @@ -118,6 +118,6 @@ public class CoverageViewManager implements PersistentStateComponent { if (newRemoteBranch) { renderer.setIconOnTheRight(true); NEW_BRANCH_LABEL.setInsets(JBUI.insets(2)); - NEW_BRANCH_LABEL.setRound(JBUI.scale(4)); + NEW_BRANCH_LABEL.setRound(JBUIScale.scale(4)); NEW_BRANCH_LABEL.setFont(NEW_BRANCH_LABEL_FONT.derive(renderer.getFont())); NEW_BRANCH_LABEL.setForeground(isSelected ? NEW_BRANCH_LABEL_SELECTION_FG : NEW_BRANCH_LABEL_FG); NEW_BRANCH_LABEL.setBackground(isSelected ? NEW_BRANCH_LABEL_SELECTION_BG : NEW_BRANCH_LABEL_BG); diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/avatars/CachingGithubAvatarIconsProvider.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/avatars/CachingGithubAvatarIconsProvider.kt index 1fbbebd19b3b..5441122c9d3e 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/avatars/CachingGithubAvatarIconsProvider.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/avatars/CachingGithubAvatarIconsProvider.kt @@ -1,10 +1,10 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.pullrequest.avatars import com.intellij.openapi.application.ModalityState import com.intellij.openapi.application.runInEdt +import com.intellij.ui.scale.ScaleContext import com.intellij.util.IconUtil -import com.intellij.util.ui.JBUIScale import com.intellij.util.ui.JBValue import icons.GithubIcons import org.jetbrains.annotations.CalledInAwt @@ -27,7 +27,7 @@ internal class CachingGithubAvatarIconsProvider(private val avatarsLoader: Cachi private val iconSize: JBValue, private val component: Component) { - private val scaleContext = JBUIScale.ScaleContext.create(component) + private val scaleContext = ScaleContext.create(component) private var defaultIcon = createDefaultIcon(iconSize.get()) private val icons = mutableMapOf() @@ -42,7 +42,7 @@ internal class CachingGithubAvatarIconsProvider(private val avatarsLoader: Cachi val iconSize = iconSize.get() // so that icons are rescaled when any scale changes (be it font size or current DPI) - if (scaleContext.update(JBUIScale.ScaleContext.create(component))) { + if (scaleContext.update(ScaleContext.create(component))) { defaultIcon = createDefaultIcon(iconSize) icons.clear() } diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GithubPullRequestsList.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GithubPullRequestsList.kt index 5574c8ae8901..55565dc04602 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GithubPullRequestsList.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/ui/GithubPullRequestsList.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.pullrequest.ui import com.intellij.ide.CopyProvider @@ -22,7 +22,6 @@ import org.jetbrains.plugins.github.pullrequest.action.GithubPullRequestKeys import org.jetbrains.plugins.github.pullrequest.avatars.CachingGithubAvatarIconsProvider import org.jetbrains.plugins.github.util.GithubUIUtil import java.awt.Component -import java.awt.FlowLayout import java.awt.datatransfer.StringSelection import java.awt.event.MouseAdapter import java.awt.event.MouseEvent diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubImageResizer.kt b/plugins/github/src/org/jetbrains/plugins/github/util/GithubImageResizer.kt index 3614569adf7b..bc4023a2af40 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubImageResizer.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubImageResizer.kt @@ -1,14 +1,14 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.util import com.intellij.openapi.Disposable import com.intellij.openapi.progress.EmptyProgressIndicator import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.util.Computable +import com.intellij.ui.scale.ScaleContext import com.intellij.util.ImageLoader import com.intellij.util.concurrency.AppExecutorUtil import com.intellij.util.ui.ImageUtil -import com.intellij.util.ui.JBUIScale import java.awt.Image import java.util.concurrent.CompletableFuture import java.util.function.Supplier @@ -18,7 +18,7 @@ class GithubImageResizer(private val progressManager: ProgressManager) : Disposa private val executor = AppExecutorUtil.createBoundedApplicationPoolExecutor("GitHub Image Resizer", getThreadPoolSize()) private val progressIndicator: EmptyProgressIndicator = NonReusableEmptyProgressIndicator() - fun requestImageResize(image: Image, size: Int, scaleContext: JBUIScale.ScaleContext): CompletableFuture { + fun requestImageResize(image: Image, size: Int, scaleContext: ScaleContext): CompletableFuture { val indicator = progressIndicator return CompletableFuture.supplyAsync(Supplier { diff --git a/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/CollectionView.java b/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/CollectionView.java index 3e2192c08c12..8e98f48e0c7e 100644 --- a/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/CollectionView.java +++ b/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/CollectionView.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.debugger.streams.ui.impl; import com.intellij.debugger.streams.trace.TraceElement; @@ -8,6 +8,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.ui.JBColor; import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBScrollPane; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; @@ -42,7 +43,7 @@ public class CollectionView extends JPanel implements TraceContainer { final JLabel label = new JBLabel(String.valueOf(tree.getItemsCount()), SwingConstants.CENTER); label.setForeground(JBColor.GRAY); final Font oldFont = label.getFont(); - label.setFont(oldFont.deriveFont(oldFont.getSize() - JBUI.scale(1.f))); + label.setFont(oldFont.deriveFont(oldFont.getSize() - JBUIScale.scale(1.f))); label.setBorder(JBUI.Borders.empty(3, 0)); return label; } diff --git a/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/MappingPane.kt b/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/MappingPane.kt index c11cd05c4343..649f6c08f570 100644 --- a/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/MappingPane.kt +++ b/plugins/stream-debugger/src/com/intellij/debugger/streams/ui/impl/MappingPane.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.debugger.streams.ui.impl import com.intellij.debugger.streams.ui.LinkedValuesMapping @@ -6,6 +6,7 @@ import com.intellij.debugger.streams.ui.TraceController import com.intellij.debugger.streams.ui.ValueWithPosition import com.intellij.ui.JBColor import com.intellij.ui.components.JBLabel +import com.intellij.ui.scale.JBUIScale import com.intellij.util.ui.GraphicsUtil import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil @@ -30,7 +31,7 @@ class MappingPane(name: String, selected = JBColor({ Color(0, 96, 229) }), inactive = JBColor({ Color(204, 204, 204) })) - val STROKE = BasicStroke(JBUI.scale(1.toFloat())) + val STROKE = BasicStroke(JBUIScale.scale(1.toFloat())) } init { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/SvnDiffViewer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/SvnDiffViewer.java index 175627e03fd8..5c190154db84 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/SvnDiffViewer.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/difftool/SvnDiffViewer.java @@ -1,3 +1,4 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.idea.svn.difftool; import com.intellij.diff.DiffContext; @@ -27,6 +28,7 @@ import com.intellij.openapi.util.Key; import com.intellij.ui.EditorNotificationPanel; import com.intellij.ui.JBColor; import com.intellij.ui.components.panels.Wrapper; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -42,8 +44,8 @@ import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; -import java.util.*; import java.util.List; +import java.util.*; public class SvnDiffViewer implements DiffViewer { private static final Logger LOG = Logger.getInstance(SvnDiffViewer.class); @@ -370,7 +372,7 @@ public class SvnDiffViewer implements DiffViewer { label.setFont(UIUtil.getOptionPaneMessageFont()); label.setForeground(UIUtil.getLabelForeground()); add(label, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, JBUI.insets(2), 0, 0)); - setDividerWidth(label.getPreferredSize().height + JBUI.scale(4)); + setDividerWidth(label.getPreferredSize().height + JBUIScale.scale(4)); revalidate(); repaint(); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java index 0442048d5e17..c17e0d51b525 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/PropertyInspectorTable.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.uiDesigner.propertyInspector; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; @@ -25,6 +25,7 @@ import com.intellij.psi.PsiMethod; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PropertyUtilBase; import com.intellij.ui.*; +import com.intellij.ui.scale.JBUIScale; import com.intellij.uiDesigner.ErrorAnalyzer; import com.intellij.uiDesigner.ErrorInfo; import com.intellij.uiDesigner.Properties; @@ -35,7 +36,10 @@ import com.intellij.uiDesigner.designSurface.GuiEditor; import com.intellij.uiDesigner.palette.Palette; import com.intellij.uiDesigner.propertyInspector.properties.*; import com.intellij.uiDesigner.radComponents.*; -import com.intellij.util.ui.*; +import com.intellij.util.ui.EmptyIcon; +import com.intellij.util.ui.IndentedIcon; +import com.intellij.util.ui.Table; +import com.intellij.util.ui.UIUtil; import icons.UIDesignerIcons; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -593,7 +597,7 @@ public final class PropertyInspectorTable extends Table implements DataProvider{ } private static int getPropertyIndentWidth() { - return JBUI.scale(11); + return JBUIScale.scale(11); } private Property[] getPropChildren(final Property property) { diff --git a/python/pluginCore/com/jetbrains/python/packaging/PyManagePackagesDialog.java b/python/pluginCore/com/jetbrains/python/packaging/PyManagePackagesDialog.java index 38862f89ac15..6107c68647a7 100644 --- a/python/pluginCore/com/jetbrains/python/packaging/PyManagePackagesDialog.java +++ b/python/pluginCore/com/jetbrains/python/packaging/PyManagePackagesDialog.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.jetbrains.python.packaging; import com.intellij.openapi.project.Project; @@ -20,7 +6,7 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.LabeledComponent; import com.intellij.ui.CollectionComboBoxModel; -import com.intellij.util.ui.JBUI; +import com.intellij.ui.scale.JBUIScale; import com.intellij.webcore.packaging.PackagesNotificationPanel; import com.jetbrains.python.packaging.ui.PyInstalledPackagesPanel; import com.jetbrains.python.sdk.PreferredSdkComparator; @@ -73,8 +59,8 @@ public class PyManagePackagesDialog extends DialogWrapper { }); init(); - myMainPanel.setPreferredSize(new Dimension(JBUI.scale(900), JBUI.scale(700))); - myMainPanel.setMinimumSize(new Dimension(JBUI.scale(900), JBUI.scale(700))); + myMainPanel.setPreferredSize(new Dimension(JBUIScale.scale(900), JBUIScale.scale(700))); + myMainPanel.setMinimumSize(new Dimension(JBUIScale.scale(900), JBUIScale.scale(700))); } @Override diff --git a/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java b/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java index a1e1817faca3..2763d6611eda 100644 --- a/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java +++ b/python/src/com/jetbrains/python/packaging/ui/PyPackageManagementService.java @@ -8,10 +8,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.scale.JBUIScale; import com.intellij.util.CatchingConsumer; import com.intellij.util.concurrency.AppExecutorUtil; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.JBUI; import com.intellij.webcore.packaging.InstalledPackage; import com.intellij.webcore.packaging.PackageManagementServiceEx; import com.intellij.webcore.packaging.RepoPackage; @@ -41,9 +41,9 @@ public class PyPackageManagementService extends PackageManagementServiceEx { @NotNull private static String buildHtmlStylePrefix() { // Shamelessly copied from Plugin Manager dialog - final int fontSize = JBUI.scale(12); - final int m1 = JBUI.scale(2); - final int m2 = JBUI.scale(5); + final int fontSize = JBUIScale.scale(12); + final int m1 = JBUIScale.scale(2); + final int m2 = JBUIScale.scale(5); return String.format("" + "