Skip to content

Commit

Permalink
Merge pull request #482 from codota/DEV2-2244-business-devision
Browse files Browse the repository at this point in the history
DEV2-2244 add business division
  • Loading branch information
yanir-codota authored Mar 7, 2023
2 parents 87a9b6a + 282673a commit 6e6d515
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/main/java/com/tabnine/binary/BinaryRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import com.tabnine.binary.fetch.BinaryVersionFetcher;
import com.tabnine.config.Config;
import com.tabnine.general.StaticConfig;
import com.tabnine.userSettings.AppSettingsState;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -80,9 +82,13 @@ private ArrayList<String> getBinaryConstantParameters(
metadata.add("clientApiVersion=" + cmdSanitize(applicationInfo.getApiVersion()));
}

if (Config.IS_ON_PREM && StaticConfig.getTabnineEnterpriseHost().isPresent()) {
constantParameters.add(
"--cloud2_url=" + cmdSanitize(StaticConfig.getTabnineEnterpriseHost().get()));
if (Config.IS_ON_PREM) {
Optional<String> enterpriseHost = StaticConfig.getTabnineEnterpriseHost();
enterpriseHost.ifPresent(s -> constantParameters.add("--cloud2_url=" + cmdSanitize(s)));
String businessDivision = AppSettingsState.getInstance().getBusinessDivision();
if (!businessDivision.isEmpty()) {
metadata.add("businessDivision=" + businessDivision);
}
}

if (additionalMetadata != null) {
Expand Down
31 changes: 30 additions & 1 deletion src/main/java/com/tabnine/userSettings/AppSettingsComponent.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tabnine.userSettings

import com.intellij.openapi.ui.ComboBox
import com.intellij.ui.components.JBCheckBox
import com.intellij.ui.components.JBLabel
import com.intellij.ui.components.JBTextField
Expand Down Expand Up @@ -31,6 +32,18 @@ class AppSettingsComponent {
JBCheckBox("Enable auto-importing packages when selecting Tabnine suggestions", true)
private val binariesFolderOverrideComponent = JXTextField(StaticConfig.getDefaultBaseDirectory().toString())
private val cloud2UrlComponent = JBTextField()
private val businessDivisionComboBox = ComboBox(
arrayOf(
"",
"Mobile eXperience",
"Visual Display",
"Networks",
"Digital Appliances",
"Health & Medical Equipment",
"Samsung Research",
"Other"
)
)

val preferredFocusedComponent: JComponent
get() = colorChooser
Expand Down Expand Up @@ -76,6 +89,11 @@ class AppSettingsComponent {
set(value) {
cloud2UrlComponent.text = value
}
var businessDivision: String
get() = businessDivisionComboBox.selectedItem as String
set(value) {
businessDivisionComboBox.selectedItem = value
}

init {
if (!suggestionsModeService.getSuggestionMode().isInlineEnabled) {
Expand All @@ -90,7 +108,18 @@ class AppSettingsComponent {
.addLabeledComponent("Log level (requires restart): ", logLevelComponent, 1, false)

if (Config.IS_ON_PREM) {
panelBuilder.addLabeledComponent("Tabnine Enterprise URL (requires restart): ", cloud2UrlComponent, 1, false)
panelBuilder.addLabeledComponent(
"Tabnine Enterprise URL (requires restart): ",
cloud2UrlComponent,
1,
false
)
panelBuilder.addLabeledComponent(
"Business Division (requires restart): ",
businessDivisionComboBox,
1,
false
)
}
if (!isFixedDebounceConfigured()) {
panelBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class AppSettingsConfigurable : Configurable {
it.debounceTime != settings.debounceTime.toString() ||
it.autoImportEnabled != settings.autoImportEnabled ||
it.binariesFolderOverride != settings.binariesFolderOverride ||
it.cloud2Url != settings.cloud2Url
it.cloud2Url != settings.cloud2Url ||
it.businessDivision != settings.businessDivision
}
}
return false
Expand All @@ -54,6 +55,7 @@ class AppSettingsConfigurable : Configurable {
settings.autoImportEnabled = settingsComponent!!.autoImportEnabled
settings.binariesFolderOverride = settingsComponent!!.binariesFolderOverride
settings.cloud2Url = settingsComponent!!.cloud2Url
settings.businessDivision = settingsComponent!!.businessDivision
}
}

Expand All @@ -68,6 +70,7 @@ class AppSettingsConfigurable : Configurable {
it.autoImportEnabled = settings.autoImportEnabled
it.binariesFolderOverride = settings.binariesFolderOverride
it.cloud2Url = settings.cloud2Url
it.businessDivision = settings.businessDivision
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/tabnine/userSettings/AppSettingsState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AppSettingsState : PersistentStateComponent<AppSettingsState?> {
var autoImportEnabled: Boolean = true
var binariesFolderOverride: String = ""
var cloud2Url: String = "https://tabnine.sec.samsung.net"
var businessDivision: String = ""

private var colorState = settingsDefaultColor

Expand Down

0 comments on commit 6e6d515

Please sign in to comment.