Skip to content

Commit

Permalink
Merge branch 'public-release/v2.0.0-231' into zowe-release/v2.0.0-231
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Apr 18, 2024
2 parents 69ae375 + 6536662 commit cad6b5d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.intellij.util.ui.ColumnInfo
import org.zowe.explorer.common.message
import org.zowe.explorer.common.ui.ErrorableTableCellRenderer
import org.zowe.explorer.config.ws.WorkingSetConfig
import javax.swing.JTable
import javax.swing.table.TableCellRenderer

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.zowe.explorer.common.ui.ValidatingCellRenderer
import org.zowe.explorer.common.ui.ValidatingColumnInfo
import org.zowe.explorer.config.ws.WorkingSetConfig
import javax.swing.JComponent
import javax.swing.JTable

/**
* Class which represents working set name column in working set table model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ package org.zowe.explorer.dataops
import org.zowe.explorer.config.connect.ConnectionConfig
import org.zowe.explorer.config.ws.DSMask
import org.zowe.explorer.dataops.fetch.LibraryQuery
import org.zowe.explorer.dataops.fetch.UssQuery
import org.zowe.explorer.dataops.sort.SortQueryKeys
import org.zowe.explorer.utils.UNIT_CLASS

Expand All @@ -34,12 +33,12 @@ class BatchedRemoteQuery<R>(
var alreadyFetched: Int = 0,
var start: String? = null,
var fetchNeeded: Boolean = true
): RemoteQuery<ConnectionConfig, R, Unit>, SortableQuery {
) : RemoteQuery<ConnectionConfig, R, Unit>, SortableQuery {
override val resultClass: Class<out Unit>
get() = UNIT_CLASS

override val sortKeys: List<SortQueryKeys>
get() = when(request) {
get() = when (request) {
is DSMask -> mutableListOf(SortQueryKeys.DATASET_MODIFICATION_DATE, SortQueryKeys.ASCENDING)
is LibraryQuery -> mutableListOf(SortQueryKeys.MEMBER_MODIFICATION_DATE, SortQueryKeys.ASCENDING)
else -> mutableListOf()
Expand All @@ -48,7 +47,7 @@ class BatchedRemoteQuery<R>(
/**
* Sets default values for params that identify current state of fetching.
*/
fun clear () {
fun clear() {
totalRows = null
start = null
fetchNeeded = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ import org.zowe.explorer.config.connect.ConnectionConfigBase
import org.zowe.explorer.config.ws.JobsFilter
import org.zowe.explorer.dataops.fetch.UssQuery
import org.zowe.explorer.dataops.sort.SortQueryKeys
import org.zowe.explorer.explorer.ui.UssNode
import org.zowe.explorer.utils.UNIT_CLASS

/**
* Class which represents Unit type of the Result of remote query
*/
data class UnitRemoteQueryImpl<Connection: ConnectionConfigBase, R>(
data class UnitRemoteQueryImpl<Connection : ConnectionConfigBase, R>(
override val request: R,
override val connectionConfig: Connection,
) : RemoteQuery<Connection, R, Unit>, SortableQuery {
override val resultClass: Class<out Unit>
get() = UNIT_CLASS
override val sortKeys: List<SortQueryKeys>
get() = when(request) {
get() = when (request) {
is UssQuery -> mutableListOf(SortQueryKeys.FILE_MODIFICATION_DATE, SortQueryKeys.ASCENDING)
is JobsFilter -> mutableListOf(SortQueryKeys.JOB_CREATION_DATE, SortQueryKeys.ASCENDING)
else -> mutableListOf()
Expand Down
21 changes: 15 additions & 6 deletions src/main/kotlin/org/zowe/explorer/explorer/ui/DSMaskNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.intellij.ide.util.treeView.AbstractTreeNode
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.ui.SimpleTextAttributes
import com.intellij.util.containers.toMutableSmartList
import org.zowe.explorer.config.connect.ConnectionConfig
import org.zowe.explorer.config.ws.DSMask
import org.zowe.explorer.dataops.BatchedRemoteQuery
Expand All @@ -38,7 +37,10 @@ class DSMaskNode(
parent: ExplorerTreeNode<ConnectionConfig, *>,
workingSet: FilesWorkingSet,
treeStructure: ExplorerTreeStructureBase,
override val currentSortQueryKeysList: List<SortQueryKeys> = mutableListOf(SortQueryKeys.DATASET_MODIFICATION_DATE, SortQueryKeys.ASCENDING),
override val currentSortQueryKeysList: List<SortQueryKeys> = mutableListOf(
SortQueryKeys.DATASET_MODIFICATION_DATE,
SortQueryKeys.ASCENDING
),
override val sortedNodes: List<AbstractTreeNode<*>> = mutableListOf()
) : RemoteMFFileFetchNode<ConnectionConfig, DSMask, DSMask, FilesWorkingSet>(
dsMask, project, parent, workingSet, treeStructure
Expand Down Expand Up @@ -81,7 +83,10 @@ class DSMaskNode(
return "Fetching listings for ${query.request.mask}"
}

override fun <Node : AbstractTreeNode<*>> sortChildrenNodes(childrenNodes: List<Node>, sortKeys: List<SortQueryKeys>): List<Node> {
override fun <Node : AbstractTreeNode<*>> sortChildrenNodes(
childrenNodes: List<Node>,
sortKeys: List<SortQueryKeys>
): List<Node> {
val listToReturn = mutableListOf<Node>()
val psFiles = childrenNodes.filter { it is FileLikeDatasetNode }
val libraries = childrenNodes.filter { it is LibraryNode }
Expand All @@ -91,7 +96,7 @@ class DSMaskNode(
val sortedLibraries = performDatasetsSorting(libraries, this@DSMaskNode, SortQueryKeys.DATASET_NAME)
listToReturn.addAll(sortedLibraries)
listToReturn.addAll(sortedPSFiles)
also { sortedNodes.clearAndMergeWith(listToReturn) }
also { sortedNodes.clearAndMergeWith(listToReturn) }
} else if (foundSortKey != null) {
listToReturn.clearAndMergeWith(performDatasetsSorting(childrenNodes, this@DSMaskNode, foundSortKey))
} else {
Expand All @@ -107,7 +112,11 @@ class DSMaskNode(
* @param sortKey
* @return sorted nodes by specified key
*/
private fun <Node: AbstractTreeNode<*>> performDatasetsSorting(nodes: List<Node>, mask: DSMaskNode, sortKey: SortQueryKeys) : List<Node> {
private fun <Node : AbstractTreeNode<*>> performDatasetsSorting(
nodes: List<Node>,
mask: DSMaskNode,
sortKey: SortQueryKeys
): List<Node> {
val sortedNodesInternal: List<Node> = if (mask.currentSortQueryKeysList.contains(SortQueryKeys.ASCENDING)) {
nodes.sortedBy {
selector(sortKey).invoke(it)
Expand All @@ -125,7 +134,7 @@ class DSMaskNode(
* @param key - sort key
* @return String representation of the extracted dataset info of the virtual file
*/
private fun selector(key: SortQueryKeys) : (AbstractTreeNode<*>) -> String? {
private fun selector(key: SortQueryKeys): (AbstractTreeNode<*>) -> String? {
return {
val datasetAttributes = when (it) {
is FileLikeDatasetNode -> service<DataOpsManager>().tryToGetAttributes(it.virtualFile) as RemoteDatasetAttributes
Expand Down
43 changes: 28 additions & 15 deletions src/main/kotlin/org/zowe/explorer/explorer/ui/LibraryNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.zowe.explorer.dataops.sort.SortQueryKeys
import org.zowe.explorer.dataops.sort.typedSortKeys
import org.zowe.explorer.explorer.FilesWorkingSet
import org.zowe.explorer.utils.clearAndMergeWith
import org.zowe.explorer.utils.service
import org.zowe.explorer.vfs.MFVirtualFile
import icons.ForMainframeIcons

Expand All @@ -51,7 +50,10 @@ class LibraryNode(
parent: ExplorerTreeNode<ConnectionConfig, *>,
workingSet: FilesWorkingSet,
treeStructure: ExplorerTreeStructureBase,
override val currentSortQueryKeysList: List<SortQueryKeys> = mutableListOf(SortQueryKeys.MEMBER_MODIFICATION_DATE, SortQueryKeys.ASCENDING),
override val currentSortQueryKeysList: List<SortQueryKeys> = mutableListOf(
SortQueryKeys.MEMBER_MODIFICATION_DATE,
SortQueryKeys.ASCENDING
),
override val sortedNodes: List<AbstractTreeNode<*>> = mutableListOf()
) : RemoteMFFileFetchNode<ConnectionConfig, MFVirtualFile, LibraryQuery, FilesWorkingSet>(
library, project, parent, workingSet, treeStructure
Expand All @@ -67,7 +69,10 @@ class LibraryNode(
}

override fun Collection<MFVirtualFile>.toChildrenNodes(): List<AbstractTreeNode<*>> {
return sortChildrenNodes(map { FileLikeDatasetNode(it, notNullProject, this@LibraryNode, unit, treeStructure) }, currentSortQueryKeysList)
return sortChildrenNodes(
map { FileLikeDatasetNode(it, notNullProject, this@LibraryNode, unit, treeStructure) },
currentSortQueryKeysList
)
}

override val requestClass = LibraryQuery::class.java
Expand All @@ -88,8 +93,11 @@ class LibraryNode(
return "Fetching members for ${query.request.library.name}"
}

override fun <Node : AbstractTreeNode<*>> sortChildrenNodes(childrenNodes: List<Node>, sortKeys: List<SortQueryKeys>): List<Node> {
val listToReturn : List<Node> = mutableListOf()
override fun <Node : AbstractTreeNode<*>> sortChildrenNodes(
childrenNodes: List<Node>,
sortKeys: List<SortQueryKeys>
): List<Node> {
val listToReturn: List<Node> = mutableListOf()
val foundSortKey = sortKeys.firstOrNull { typedSortKeys.contains(it) }
if (foundSortKey != null) {
listToReturn.clearAndMergeWith(performMembersSorting(childrenNodes, this@LibraryNode, foundSortKey))
Expand All @@ -106,16 +114,21 @@ class LibraryNode(
* @param sortKey
* @return sorted nodes by specified key
*/
private fun performMembersSorting(nodes: List<AbstractTreeNode<*>>, dataset: LibraryNode, sortKey: SortQueryKeys) : List<AbstractTreeNode<*>> {
val sortedNodesInternal: List<AbstractTreeNode<*>> = if (dataset.currentSortQueryKeysList.contains(SortQueryKeys.ASCENDING)) {
nodes.sortedBy {
selector(sortKey).invoke(it)
private fun performMembersSorting(
nodes: List<AbstractTreeNode<*>>,
dataset: LibraryNode,
sortKey: SortQueryKeys
): List<AbstractTreeNode<*>> {
val sortedNodesInternal: List<AbstractTreeNode<*>> =
if (dataset.currentSortQueryKeysList.contains(SortQueryKeys.ASCENDING)) {
nodes.sortedBy {
selector(sortKey).invoke(it)
}
} else {
nodes.sortedByDescending {
selector(sortKey).invoke(it)
}
}
} else {
nodes.sortedByDescending {
selector(sortKey).invoke(it)
}
}
return sortedNodesInternal.also { sortedNodes.clearAndMergeWith(it) }
}

Expand All @@ -124,7 +137,7 @@ class LibraryNode(
* @param key - sort key
* @return String representation of the extracted member info attribute of the virtual file
*/
private fun selector(key: SortQueryKeys) : (AbstractTreeNode<*>) -> String? {
private fun selector(key: SortQueryKeys): (AbstractTreeNode<*>) -> String? {
return {
val memberInfo =
(service<DataOpsManager>().tryToGetAttributes((it as FileLikeDatasetNode).virtualFile) as RemoteMemberAttributes).info
Expand Down

0 comments on commit cad6b5d

Please sign in to comment.