diff --git a/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt b/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt index cfbb452dcaeb..c0ab98a9adf3 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/MigLayoutBuilder.kt @@ -317,9 +317,12 @@ private fun createComponentConstraints(constraints: Array? = null, } if (growPolicy == GrowPolicy.SHORT_TEXT) { -// cc().minWidth("210") cc().maxWidth("210") } + else if (growPolicy == GrowPolicy.MEDIUM_TEXT) { + cc().minWidth("210") + cc().maxWidth("350") + } return _cc } diff --git a/platform/platform-impl/src/com/intellij/ui/layout/Row.kt b/platform/platform-impl/src/com/intellij/ui/layout/Row.kt index 75bf50abfad7..ff0e1998aa04 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/Row.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/Row.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * 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. @@ -148,5 +148,5 @@ abstract class Row() { } enum class GrowPolicy { - SHORT_TEXT + SHORT_TEXT, MEDIUM_TEXT } \ No newline at end of file diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index dca03e9be781..9647a5d61a6b 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -585,6 +585,8 @@ key="browsers.settings" bundle="messages.IdeBundle"/> + + diff --git a/xml/impl/src/com/intellij/ide/browsers/LaunchBrowserBeforeRunTaskProvider.kt b/xml/impl/src/com/intellij/ide/browsers/LaunchBrowserBeforeRunTaskProvider.kt new file mode 100644 index 000000000000..99c169ee681a --- /dev/null +++ b/xml/impl/src/com/intellij/ide/browsers/LaunchBrowserBeforeRunTaskProvider.kt @@ -0,0 +1,99 @@ +/* + * 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. + */ +package com.intellij.ide.browsers + +import com.intellij.execution.BeforeRunTask +import com.intellij.execution.BeforeRunTaskProvider +import com.intellij.execution.configurations.RunConfiguration +import com.intellij.execution.runners.ExecutionEnvironment +import com.intellij.icons.AllIcons +import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.components.BaseState +import com.intellij.openapi.ui.TextFieldWithBrowseButton +import com.intellij.openapi.util.Key +import com.intellij.ui.components.CheckBox +import com.intellij.ui.components.dialog +import com.intellij.ui.layout.* +import com.intellij.util.ui.UIUtil +import com.intellij.util.xmlb.annotations.Attribute +import com.intellij.xml.XmlBundle +import javax.swing.Icon +import javax.swing.border.EmptyBorder + +internal class LaunchBrowserBeforeRunTaskProvider : BeforeRunTaskProvider() { + companion object { + val ID = Key.create("LaunchBrowser.Before.Run") + } + + override fun getName() = "Launch Web Browser" + + override fun getId() = ID + + override fun getIcon(): Icon = AllIcons.Nodes.PpWeb + + override fun isConfigurable() = true + + override fun createTask(runConfiguration: RunConfiguration) = LaunchBrowserBeforeRunTask() + + override fun configureTask(runConfiguration: RunConfiguration, task: LaunchBrowserBeforeRunTask): Boolean { + val browserSelector = BrowserSelector() + val browserComboBox = browserSelector.mainComponent + if (UIUtil.isUnderAquaLookAndFeel()) { + browserComboBox.border = EmptyBorder(3, 0, 0, 0) + } + + val url = TextFieldWithBrowseButton() + StartBrowserPanel.setupUrlField(url, runConfiguration.project) + + val startJavaScriptDebuggerCheckBox = if (JavaScriptDebuggerStarter.Util.hasStarters()) CheckBox(XmlBundle.message("start.browser.with.js.debugger")) else null + + val modificationCount = task.state.modificationCount + val panel = panel { + row("Browser:") { + browserComboBox() + startJavaScriptDebuggerCheckBox?.invoke() + } + row("Url:") { + url(growPolicy = GrowPolicy.MEDIUM_TEXT) + } + } + dialog("Launch Web Browser", panel = panel, resizable = true) + .show() + + task.state.browser = browserSelector.selected + if (startJavaScriptDebuggerCheckBox != null) { + task.state.withDebugger = startJavaScriptDebuggerCheckBox.isSelected + } + return modificationCount != task.state.modificationCount + } + + override fun executeTask(context: DataContext?, + configuration: RunConfiguration?, + env: ExecutionEnvironment?, + task: LaunchBrowserBeforeRunTask?): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} + +internal class LaunchBrowserBeforeRunTaskState : BaseState() { + @get:Attribute(value = "browser", converter = WebBrowserReferenceConverter::class) + var browser by storedProperty() + var withDebugger by storedProperty(false) +} + +internal class LaunchBrowserBeforeRunTask : BeforeRunTask(LaunchBrowserBeforeRunTaskProvider.ID) { + val state = LaunchBrowserBeforeRunTaskState() +} \ No newline at end of file