Skip to content

Commit

Permalink
Fixed release/v2.0.0 branch
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Sep 24, 2024
1 parent f2de31f commit 601dc49
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 169 deletions.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ dependencies {
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
testImplementation("com.squareup.okhttp3:mockwebserver:$okHttp3Version")
testImplementation("com.squareup.okhttp3:okhttp-tls:$okHttp3Version")
testImplementation("com.squareup.okhttp3:logging-interceptor:$okHttp3Version")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:$junitVersion")
testImplementation("com.intellij.remoterobot:ide-launcher:$remoteRobotVersion")
Expand Down Expand Up @@ -234,6 +235,9 @@ tasks {
test {
useJUnitPlatform()

// To run unit tests only and do not trigger "uiTest" task related things (like "compileUiTestKotlin")
onlyIf { !gradle.startParameter.taskNames.contains("uiTest") }

jvmArgs("--add-opens", "java.desktop/java.awt=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/sun.awt=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/java.awt.event=ALL-UNNAMED")
Expand All @@ -258,7 +262,7 @@ tasks {
if (desc.parent == null) { // will match the outermost suite
val output =
"Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, " +
"${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
"${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
val fileName = "./build/reports/tests/${result.resultType}.txt"
File(fileName).writeText(output)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.explorer.config.connect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.explorer.config.connect.ui.zosmf
Expand Down Expand Up @@ -161,15 +165,15 @@ abstract class CommonConnectionDialog(
newState.isAllowSsl,
newState.zVersion
)
CredentialService.instance.setCredentials(
CredentialService.getService().setCredentials(
connectionConfigUuid = newState.connectionUuid,
username = newState.username,
password = newState.password
)
} else {
state.initEmptyUuids(crudable)
newTestedConnConfig = state.connectionConfig
CredentialService.instance.setCredentials(
CredentialService.getService().setCredentials(
connectionConfigUuid = state.connectionUuid,
username = state.username,
password = state.password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import com.intellij.openapi.options.BoundSearchableConfigurable
import com.intellij.openapi.progress.runBackgroundableTask
import com.intellij.openapi.ui.DialogPanel
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.showOkCancelDialog
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.ui.dsl.builder.panel
import org.zowe.explorer.common.ui.DEFAULT_ROW_HEIGHT
import org.zowe.explorer.common.ui.DialogMode
Expand All @@ -34,9 +36,14 @@ import org.zowe.explorer.config.ws.JesWorkingSetConfig
import org.zowe.explorer.config.ws.WorkingSetConfig
import org.zowe.explorer.utils.crudable.getAll
import org.zowe.explorer.utils.isThe
import org.zowe.explorer.utils.runWriteActionInEdtAndWait
import org.zowe.explorer.utils.toMutableList
import org.zowe.explorer.zowe.service.ZoweConfigServiceImpl
import org.zowe.kotlinsdk.zowe.config.ZoweConfig
import org.zowe.kotlinsdk.zowe.config.parseConfigJson
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import java.net.URI

/** Create and manage Connections tab in settings */
@Suppress("DialogTitleCapitalization")
Expand Down Expand Up @@ -72,7 +79,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
throw IllegalStateException("Unable to save invalid URL: ${state.connectionUrl}")
setProfile(ZoweConfigServiceImpl.getProfileNameFromConnName(state.connectionName))
host = uri.host
port = if (uri.port==-1) 10443 else uri.port.toLong()
port = if (uri.port == -1) 10443 else uri.port.toLong()
protocol = state.connectionUrl.split("://")[0]
user = state.username
password = state.password
Expand Down Expand Up @@ -149,16 +156,51 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
}
}

/** Generates a connection removal warning message that is used for working sets */
private fun generateRemoveWarningMessage(wsUsages: List<WorkingSetConfig>, wsType: String): StringBuilder {
val warningMessageBuilder =
StringBuilder("<nobr>The following $wsType working sets use selected connections:</nobr><br>")
wsUsages.forEach { wsConfig ->
warningMessageBuilder.append(wsConfig.name).append(", ")
companion object {
/**
* Generates a connection removal warning message that is used for Files/JES working set
* @param wsUsages list of working sets for the current connection
* @param wsType working set type
* @return StringBuilder with result string.
*/
private fun generateRemoveWarningMessage(wsUsages: List<WorkingSetConfig>, wsType: String): StringBuilder {
val warningMessageBuilder =
StringBuilder("<nobr>The following $wsType working sets use selected connections:</nobr><br>")
wsUsages.forEach { wsConfig ->
warningMessageBuilder.append(wsConfig.name).append(", ")
}
warningMessageBuilder.setLength(warningMessageBuilder.length - 2)
warningMessageBuilder.append(".<br>")
return warningMessageBuilder
}

/**
* Creates a message dialog when a connection is deleted if it is used in any working set
* @param filesWsUsages list of files working sets
* @param jesWsUsages list of JES working sets
* @return number of button pressed
*/
fun warningMessageForDeleteConfig(
filesWsUsages: List<FilesWorkingSetConfig>,
jesWsUsages: List<JesWorkingSetConfig>
): Int {
val warningMessageBuilder = StringBuilder()
if (filesWsUsages.isNotEmpty()) {
warningMessageBuilder.append(generateRemoveWarningMessage(filesWsUsages, "Files"))
}
if (jesWsUsages.isNotEmpty()) {
warningMessageBuilder.append(generateRemoveWarningMessage(jesWsUsages, "JES"))
}
warningMessageBuilder.append("<br>Do you really want to remove it?")

return Messages.showOkCancelDialog(
warningMessageBuilder.toString(),
"Warning",
"Yes",
"Cancel",
Messages.getWarningIcon()
)
}
warningMessageBuilder.setLength(warningMessageBuilder.length - 2)
warningMessageBuilder.append(".<br>")
return warningMessageBuilder
}

/** Remove connections with the warning before they are deleted */
Expand All @@ -184,22 +226,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
return
}

val warningMessageBuilder = StringBuilder()
if (filesWsUsages.isNotEmpty()) {
warningMessageBuilder.append(generateRemoveWarningMessage(filesWsUsages, "Files"))
}
if (jesWsUsages.isNotEmpty()) {
warningMessageBuilder.append(generateRemoveWarningMessage(jesWsUsages, "JES"))
}
warningMessageBuilder.append("<br>Do you really want to remove it?")

val ret = Messages.showOkCancelDialog(
warningMessageBuilder.toString(),
"Warning",
"Yes",
"Cancel",
Messages.getWarningIcon()
)
val ret = warningMessageForDeleteConfig(filesWsUsages, jesWsUsages)

if (ret == Messages.OK)
removeSelectedConnections()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.explorer.config.connect.ui.zosmf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.explorer.explorer.actions
Expand All @@ -14,9 +18,8 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.components.service
import com.intellij.openapi.vfs.VirtualFileManager
import org.zowe.explorer.config.configCrudable
import org.zowe.explorer.config.ConfigService
import org.zowe.explorer.config.connect.CredentialService
import org.zowe.explorer.config.connect.ui.zosmf.ConnectionDialogState
import org.zowe.explorer.config.connect.ui.zosmf.ZoweTeamConfigDialog
Expand Down Expand Up @@ -60,6 +63,7 @@ class AddZoweTeamConfigAction : AnAction() {
* @see com.intellij.openapi.actionSystem.AnAction.actionPerformed
*/
override fun actionPerformed(e: AnActionEvent) {
val configCrudable = ConfigService.getService().crudable
val state = ZoweTeamConfigDialog.showAndTestConnection(
crudable = configCrudable,
project = e.project,
Expand All @@ -72,10 +76,10 @@ class AddZoweTeamConfigAction : AnAction() {
e.presentation.description = "$ZOWE_CONFIG_NAME already exists in the project"
return
}
val zoweConfigService = project.service<ZoweConfigService>()
val zoweConfigService = ZoweConfigService.getInstance(project)
zoweConfigService.addZoweConfigFile(state)

CredentialService.instance.setCredentials(connectionConfig.uuid, state.username, state.password)
CredentialService.getService().setCredentials(connectionConfig.uuid, state.username, state.password)
configCrudable.add(connectionConfig)
} else {
return
Expand Down
14 changes: 9 additions & 5 deletions src/main/kotlin/org/zowe/explorer/zowe/ZoweStartupActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.explorer.zowe
Expand All @@ -14,7 +18,6 @@ import com.intellij.icons.AllIcons
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.components.service
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
Expand All @@ -36,7 +39,7 @@ const val ZOWE_CONFIG_NAME = "zowe.config.json"
* @return Nothing.
*/
fun showNotificationForAddUpdateZoweConfigIfNeeded(project: Project, type: ZoweConfigType) {
val zoweConfigService = project.service<ZoweConfigService>()
val zoweConfigService = ZoweConfigService.getInstance(project)
val zoweConfigState = zoweConfigService.getZoweConfigState(type = type)

if (zoweConfigState == ZoweConfigState.NEED_TO_ADD) {
Expand All @@ -57,7 +60,8 @@ fun showNotificationForAddUpdateZoweConfigIfNeeded(project: Project, type: ZoweC
})
addAction(object : DumbAwareAction("Add $type Zowe Connection") {
override fun actionPerformed(e: AnActionEvent) {
project.service<ZoweConfigService>().addOrUpdateZoweConfig(false, true, type)
ZoweConfigService.getInstance(project)
.addOrUpdateZoweConfig(false, true, type)
hideBalloon()
}
}).notify(project)
Expand All @@ -71,7 +75,7 @@ fun showNotificationForAddUpdateZoweConfigIfNeeded(project: Project, type: ZoweC
* @return Nothing.
*/
fun showDialogForDeleteZoweConfigIfNeeded(project: Project, type: ZoweConfigType) {
val zoweConfigService = project.service<ZoweConfigService>()
val zoweConfigService = ZoweConfigService.getInstance(project)
val zoweConfigState = zoweConfigService.getZoweConfigState(type = type)
if (zoweConfigState != ZoweConfigState.NEED_TO_ADD && zoweConfigState != ZoweConfigState.NOT_EXISTS) {
val choice = Messages.showDialog(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.explorer.zowe.actions

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.components.service
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.project.DumbAwareAction
import org.zowe.explorer.utils.write
Expand Down Expand Up @@ -50,7 +53,7 @@ class UpdateZoweConfigAction : DumbAwareAction() {

FileDocumentManager.getInstance().saveDocument(editor.document)

val zoweConfigService = project.service<ZoweConfigService>()
val zoweConfigService = ZoweConfigService.getInstance(project)

zoweConfigService.addOrUpdateZoweConfig(true, type = type)
}
Expand All @@ -75,7 +78,7 @@ class UpdateZoweConfigAction : DumbAwareAction() {
if (vFile.path == zoweLocalConfigLocation)
type = ZoweConfigType.LOCAL

val zoweConfigService = project.service<ZoweConfigService>()
val zoweConfigService = ZoweConfigService.getInstance(project)
lock.write {
val prevZoweConfig = if (type == ZoweConfigType.LOCAL)
zoweConfigService.localZoweConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* Copyright (c) 2020-2024 IBA Group.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
* Contributors:
* IBA Group
* Zowe Community
*/

package org.zowe.explorer.zowe.service
Expand Down
Loading

0 comments on commit 601dc49

Please sign in to comment.