Skip to content

Commit 4d7670b

Browse files
authored
refactor: package relocating (#794)
* refactor: package relocating * encoding issue * refactor: package relocating * docs: license header
1 parent b950792 commit 4d7670b

File tree

54 files changed

+361
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+361
-270
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Source++, the open-source live coding platform.
3+
* Copyright (C) 2022 CodeBrig, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package spp.jetbrains
18+
19+
import com.intellij.AbstractBundle
20+
import com.intellij.ide.plugins.PluginManager
21+
import com.intellij.openapi.extensions.PluginId
22+
import org.jetbrains.annotations.NonNls
23+
import org.jetbrains.annotations.PropertyKey
24+
import java.util.*
25+
26+
@NonNls
27+
private const val BUNDLE = "messages.PluginBundle"
28+
29+
/**
30+
* todo: description.
31+
*
32+
* @since 0.2.0
33+
* @author [Brandon Fergerson](mailto:[email protected])
34+
*/
35+
object PluginBundle : AbstractBundle(BUNDLE) {
36+
37+
val LOCALE: Locale by lazy {
38+
val chineseLanguagePlugin = "com.intellij.zh"
39+
if (PluginManager.isPluginInstalled(PluginId.getId(chineseLanguagePlugin))) {
40+
Locale.CHINA
41+
} else {
42+
Locale.ROOT
43+
}
44+
}
45+
46+
//todo: shouldn't need to manually load bundle.
47+
val LOCALE_BUNDLE: ResourceBundle by lazy {
48+
ResourceBundle.getBundle(BUNDLE, LOCALE, PluginBundle::class.java.classLoader)
49+
}
50+
51+
@Suppress("SpreadOperator")
52+
@JvmStatic
53+
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String {
54+
return try {
55+
LOCALE_BUNDLE.getString(key) ?: getMessage(key, *params)
56+
} catch (ignore: MissingResourceException) {
57+
key // no translation found
58+
}
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
* Source++, the open-source live coding platform.
3+
* Copyright (C) 2022 CodeBrig, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package spp.jetbrains
18+
19+
import com.intellij.ui.Gray
20+
import com.intellij.ui.JBColor
21+
import com.intellij.util.ui.UIUtil
22+
import spp.jetbrains.PluginBundle.LOCALE
23+
import java.awt.Color
24+
import java.awt.Font
25+
import javax.swing.border.LineBorder
26+
27+
object PluginUI {
28+
29+
@JvmField
30+
val LABEL_FOREGROUND_COLOR = Color(152, 118, 170)
31+
32+
@JvmField
33+
val LABEL_FOREGROUND_COLOR1 = Color(106, 135, 89)
34+
35+
@JvmField
36+
val EXPIRY_FOREGROUND_COLOR: Color = Color.decode("#BBBBBB")
37+
38+
@JvmField
39+
val SELECT_COLOR_RED: Color = Color.decode("#e1483b")
40+
41+
@JvmField
42+
val COMPLETE_COLOR_PURPLE: Color = Color.decode("#9876AA")
43+
44+
@JvmField
45+
val STATUS_BAR_TXT_BG_COLOR = JBColor(JBColor.WHITE, Gray._37)
46+
47+
@JvmField
48+
val CONTROL_BAR_CMD_FOREGROUND = JBColor(JBColor.BLACK, JBColor.GRAY)
49+
50+
@JvmField
51+
val DFLT_BGND_COLOR = JBColor(Gray._242, Gray._50)
52+
53+
@JvmField
54+
val CNFG_PANEL_BGND_COLOR = JBColor(Gray._242, Gray._37)
55+
56+
@JvmField
57+
val BGND_FOCUS_COLOR = JBColor(Gray._175, Gray._25)
58+
59+
@JvmField
60+
val COMMAND_TYPE_COLOR = JBColor(JBColor.BLACK, Gray._125)
61+
62+
@JvmField
63+
val COMMAND_HIGHLIGHT_COLOR = JBColor(SELECT_COLOR_RED, Color.decode("#E6E6E6"))
64+
65+
@JvmStatic
66+
val commandTypeColor: String
67+
get() = "#" + Integer.toHexString(COMMAND_TYPE_COLOR.rgb).substring(2)
68+
69+
@JvmStatic
70+
val commandHighlightColor: String
71+
get() = "#" + Integer.toHexString(COMMAND_HIGHLIGHT_COLOR.rgb).substring(2)
72+
73+
@JvmStatic
74+
val editCompleteColor: Color
75+
get() = UIUtil.getWindowColor()
76+
77+
@JvmField
78+
val PANEL_BACKGROUND_COLOR: Color = Gray._37
79+
80+
@JvmField
81+
val PANEL_BORDER = LineBorder(Gray._85)
82+
83+
@JvmField
84+
val ROBOTO_LIGHT_BOLD_14: Font
85+
86+
private val ROBOTO_LIGHT_PLAIN_13: Font
87+
private val ROBOTO_LIGHT_PLAIN_14: Font
88+
private val ROBOTO_LIGHT_PLAIN_15: Font
89+
private val ROBOTO_LIGHT_PLAIN_16: Font
90+
private val ROBOTO_LIGHT_PLAIN_17: Font
91+
private val MICROSOFT_YAHEI_PLAIN_12: Font
92+
private val MICROSOFT_YAHEI_PLAIN_13: Font
93+
94+
@JvmField
95+
val MICROSOFT_YAHEI_PLAIN_14: Font
96+
private val MICROSOFT_YAHEI_PLAIN_15: Font
97+
private val MICROSOFT_YAHEI_PLAIN_16: Font
98+
99+
init {
100+
try {
101+
val robotoLightFont = Font.createFont(
102+
Font.TRUETYPE_FONT,
103+
PluginUI::class.java.getResourceAsStream("/fonts/Roboto-Light.ttf")
104+
)
105+
ROBOTO_LIGHT_BOLD_14 = robotoLightFont.deriveFont(Font.BOLD).deriveFont(14f)
106+
ROBOTO_LIGHT_PLAIN_13 = robotoLightFont.deriveFont(Font.PLAIN).deriveFont(13f)
107+
ROBOTO_LIGHT_PLAIN_14 = robotoLightFont.deriveFont(Font.PLAIN).deriveFont(14f)
108+
ROBOTO_LIGHT_PLAIN_15 = robotoLightFont.deriveFont(Font.PLAIN).deriveFont(15f)
109+
ROBOTO_LIGHT_PLAIN_16 = robotoLightFont.deriveFont(Font.PLAIN).deriveFont(16f)
110+
ROBOTO_LIGHT_PLAIN_17 = robotoLightFont.deriveFont(Font.PLAIN).deriveFont(17f)
111+
112+
val yaheiFont = Font.createFont(
113+
Font.TRUETYPE_FONT,
114+
PluginUI::class.java.getResourceAsStream("/fonts/chinese.msyh.ttf")
115+
)
116+
MICROSOFT_YAHEI_PLAIN_12 = yaheiFont.deriveFont(Font.PLAIN).deriveFont(12f)
117+
MICROSOFT_YAHEI_PLAIN_13 = yaheiFont.deriveFont(Font.PLAIN).deriveFont(13f)
118+
MICROSOFT_YAHEI_PLAIN_14 = yaheiFont.deriveFont(Font.PLAIN).deriveFont(14f)
119+
MICROSOFT_YAHEI_PLAIN_15 = yaheiFont.deriveFont(Font.PLAIN).deriveFont(15f)
120+
MICROSOFT_YAHEI_PLAIN_16 = yaheiFont.deriveFont(Font.PLAIN).deriveFont(16f)
121+
} catch (e: Exception) {
122+
throw RuntimeException(e)
123+
}
124+
}
125+
126+
@JvmField
127+
val BIG_FONT = if (LOCALE.language == "zh") MICROSOFT_YAHEI_PLAIN_16 else ROBOTO_LIGHT_PLAIN_17
128+
129+
@JvmField
130+
val SMALL_FONT = if (LOCALE.language == "zh") MICROSOFT_YAHEI_PLAIN_15 else ROBOTO_LIGHT_PLAIN_16
131+
132+
@JvmField
133+
val SMALLER_FONT = if (LOCALE.language == "zh") MICROSOFT_YAHEI_PLAIN_14 else ROBOTO_LIGHT_PLAIN_15
134+
135+
@JvmField
136+
val SMALLEST_FONT = if (LOCALE.language == "zh") MICROSOFT_YAHEI_PLAIN_13 else ROBOTO_LIGHT_PLAIN_14
137+
138+
@JvmField
139+
val SUPER_SMALLEST_FONT = if (LOCALE.language == "zh") MICROSOFT_YAHEI_PLAIN_12 else ROBOTO_LIGHT_PLAIN_13
140+
}

common/src/main/kotlin/spp/jetbrains/sourcemarker/UserData.kt renamed to common/src/main/kotlin/spp/jetbrains/UserData.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package spp.jetbrains.sourcemarker
17+
package spp.jetbrains
1818

1919
import com.intellij.openapi.project.Project
2020
import com.intellij.openapi.util.Key

common/src/main/kotlin/spp/jetbrains/sourcemarker/icons/PluginIcons.kt renamed to common/src/main/kotlin/spp/jetbrains/icons/PluginIcons.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package spp.jetbrains.sourcemarker.icons
17+
package spp.jetbrains.icons
1818

1919
import com.intellij.openapi.util.IconLoader
2020

common/src/main/kotlin/spp/jetbrains/sourcemarker/status/SourceStatus.kt renamed to common/src/main/kotlin/spp/jetbrains/status/SourceStatus.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package spp.jetbrains.sourcemarker.status
17+
package spp.jetbrains.status
1818

19-
import spp.jetbrains.sourcemarker.icons.PluginIcons
19+
import spp.jetbrains.icons.PluginIcons
2020
import javax.swing.Icon
2121

2222
enum class SourceStatus {

common/src/main/kotlin/spp/jetbrains/sourcemarker/status/SourceStatusService.kt renamed to common/src/main/kotlin/spp/jetbrains/status/SourceStatusService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package spp.jetbrains.sourcemarker.status
17+
package spp.jetbrains.status
1818

1919
import com.intellij.openapi.project.Project
2020
import com.intellij.openapi.util.Key

core/build.gradle.kts

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ dependencies {
2424
compileOnly("plus.sourceplus:protocol:$projectVersion")
2525
compileOnly("io.vertx:vertx-core:$vertxVersion")
2626
compileOnly("io.vertx:vertx-lang-kotlin-coroutines:$vertxVersion")
27+
compileOnly("com.apollographql.apollo3:apollo-api:$apolloVersion")
2728

2829
compileOnly("com.jetbrains.intellij.platform:ide:$intellijVersion")
29-
compileOnly("com.jetbrains.intellij.platform:ide-impl:$intellijVersion")
30-
compileOnly("com.jetbrains.intellij.platform:core:$intellijVersion")
31-
compileOnly("com.jetbrains.intellij.platform:core-impl:$intellijVersion")
32-
compileOnly("com.jetbrains.intellij.platform:core-ui:$intellijVersion")
33-
compileOnly("com.jetbrains.intellij.platform:code-style:$intellijVersion")
34-
compileOnly("com.jetbrains.intellij.platform:lang:$intellijVersion")
35-
compileOnly("com.jetbrains.intellij.platform:lang-impl:$intellijVersion")
36-
compileOnly("com.apollographql.apollo3:apollo-api:$apolloVersion")
3730
}

core/src/main/kotlin/spp/command/LiveCommand.kt renamed to core/src/main/kotlin/spp/jetbrains/command/LiveCommand.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package spp.command
17+
package spp.jetbrains.command
1818

1919
import com.intellij.openapi.application.ApplicationManager
2020
import com.intellij.openapi.project.Project
2121
import kotlinx.coroutines.runBlocking
22-
import liveplugin.implementation.plugin.LiveStatusManager
22+
import spp.jetbrains.UserData
2323
import spp.jetbrains.marker.source.mark.api.SourceMark
24-
import spp.jetbrains.sourcemarker.UserData
24+
import spp.jetbrains.plugin.LiveStatusManager
2525
import javax.swing.Icon
2626

2727
@Suppress("unused")

core/src/main/kotlin/spp/command/LiveCommandContext.kt renamed to core/src/main/kotlin/spp/jetbrains/command/LiveCommandContext.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package spp.command
17+
package spp.jetbrains.command
1818

1919
import com.intellij.psi.PsiElement
2020
import spp.jetbrains.marker.source.SourceFileMarker

core/src/main/kotlin/spp/indicator/LiveIndicator.kt renamed to core/src/main/kotlin/spp/jetbrains/indicator/LiveIndicator.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package spp.indicator
17+
package spp.jetbrains.indicator
1818

1919
import com.apollographql.apollo3.exception.ApolloException
2020
import com.intellij.openapi.diagnostic.logger
@@ -25,10 +25,10 @@ import kotlinx.coroutines.launch
2525
import spp.jetbrains.marker.source.mark.api.event.IEventCode
2626
import spp.jetbrains.marker.source.mark.api.event.SourceMarkEvent
2727
import spp.jetbrains.marker.source.mark.guide.GuideMark
28-
import spp.jetbrains.sourcemarker.UserData
29-
import spp.jetbrains.sourcemarker.status.SourceStatus.ConnectionError
30-
import spp.jetbrains.sourcemarker.status.SourceStatus.Ready
31-
import spp.jetbrains.sourcemarker.status.SourceStatusService
28+
import spp.jetbrains.UserData
29+
import spp.jetbrains.status.SourceStatus.ConnectionError
30+
import spp.jetbrains.status.SourceStatus.Ready
31+
import spp.jetbrains.status.SourceStatusService
3232

3333
@Suppress("unused")
3434
abstract class LiveIndicator(val project: Project) {

core/src/main/kotlin/liveplugin/implementation/plugin/LivePluginService.kt renamed to core/src/main/kotlin/spp/jetbrains/plugin/LivePluginService.kt

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
* Source++, the open-source live coding platform.
33
* Copyright (C) 2022 CodeBrig, Inc.
44
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU Affero General Public License as published
7-
* by the Free Software Foundation, either version 3 of the License, or
8-
* (at your option) any later version.
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
98
*
10-
* This program is distributed in the hope that it will be useful,
11-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
* GNU Affero General Public License for more details.
9+
* http://www.apache.org/licenses/LICENSE-2.0
1410
*
15-
* You should have received a copy of the GNU Affero General Public License
16-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1716
*/
18-
package liveplugin.implementation.plugin
17+
package spp.jetbrains.plugin
1918

2019
import com.intellij.openapi.project.Project
2120
import com.intellij.openapi.util.Key
22-
import spp.command.LiveCommand
23-
import spp.indicator.LiveIndicator
21+
import spp.jetbrains.command.LiveCommand
22+
import spp.jetbrains.indicator.LiveIndicator
2423
import spp.jetbrains.marker.source.mark.api.SourceMark
2524
import java.io.File
2625

core/src/main/kotlin/liveplugin/implementation/plugin/LiveStatusManager.kt renamed to core/src/main/kotlin/spp/jetbrains/plugin/LiveStatusManager.kt

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
* Source++, the open-source live coding platform.
33
* Copyright (C) 2022 CodeBrig, Inc.
44
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU Affero General Public License as published
7-
* by the Free Software Foundation, either version 3 of the License, or
8-
* (at your option) any later version.
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
98
*
10-
* This program is distributed in the hope that it will be useful,
11-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
* GNU Affero General Public License for more details.
9+
* http://www.apache.org/licenses/LICENSE-2.0
1410
*
15-
* You should have received a copy of the GNU Affero General Public License
16-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
1716
*/
18-
package liveplugin.implementation.plugin
17+
package spp.jetbrains.plugin
1918

2019
import com.intellij.openapi.editor.Editor
2120
import com.intellij.openapi.project.Project

0 commit comments

Comments
 (0)