Skip to content

Commit

Permalink
Slightly prettify popup message about project configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
zarechenskiy committed Sep 30, 2016
1 parent 66709bc commit bdd82ce
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ package org.jetbrains.kotlin.ui.launch
import org.eclipse.core.resources.IProject
import org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup
import org.eclipse.swt.SWT
import org.eclipse.swt.custom.StyleRange
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.graphics.Image
import org.eclipse.swt.layout.GridLayout
import org.eclipse.swt.widgets.Composite
import org.eclipse.swt.widgets.Display
import org.eclipse.swt.widgets.Label
import org.jetbrains.kotlin.core.utils.ProjectUtils
import org.jetbrains.kotlin.ui.gridData
import org.eclipse.swt.custom.StyledText
import org.eclipse.ui.ISharedImages
import org.eclipse.ui.PlatformUI
import org.jetbrains.kotlin.core.KotlinClasspathContainer
import org.jetbrains.kotlin.core.utils.ProjectUtils
import org.jetbrains.kotlin.ui.gridData
import org.eclipse.swt.custom.StyleRange

class KotlinRuntimeConfigurator(private val project: IProject) : Runnable {
companion object {
Expand Down Expand Up @@ -59,25 +60,27 @@ private class RuntimeNotificationPopup(display: Display) : AbstractNotificationP
}

override fun createContentArea(parent: Composite) {
val parentLayout = GridLayout(1, true)

parent.setLayout(parentLayout)
parent.setLayoutData(gridData())
parent.setLayout(GridLayout(1, true))
parent.setLayoutData(gridData().apply { widthHint = 300 })

StyledText(parent, SWT.LEFT).apply {
setText("$RUNTIME_JAR, $REFLECT_JAR were added to the project classpath.")
setText("$RUNTIME_JAR, $REFLECT_JAR were added\nto the project classpath.")
makeBold(RUNTIME_JAR, REFLECT_JAR)
}
}

override fun getPopupShellTitle(): String = "Configure Kotlin in Project"

override fun getPopupShellImage(maximumHeight: Int): Image? {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
}

private fun StyledText.makeBold(vararg strs: String) {
val styleRanges = strs.mapNotNull { str ->
val start = text.indexOf(str)
if (start < 0) return@mapNotNull null

StyleRange(start, str.length, foreground, background, SWT.BOLD)
StyleRange(start, str.length, null, null, SWT.BOLD)
}

setStyleRanges(styleRanges.toTypedArray())
Expand Down

0 comments on commit bdd82ce

Please sign in to comment.