@@ -650,160 +650,6 @@ async function pickAdditions(
650650 } ) ;
651651}
652652
653- /**
654- * Show an expandable QuickPick to let the user pick a single class from the server.
655- * Packages can be expanded to reveal their classes. Only leaf class items can be accepted.
656- * - Returns the class name (without the `.cls` extension) when a class is picked.
657- * - Returns `""` when the user presses Escape (skip this optional step).
658- * - Returns `undefined` when the user presses the Back button (only when `canGoBack` is `true`).
659- */
660- export async function pickClass ( api : AtelierAPI , title : string , canGoBack = false ) : Promise < string | undefined > {
661- const query = "SELECT Name, Type FROM %Library.RoutineMgr_StudioOpenDialog(?,1,1,?,0,0,?)" ;
662- let sys : "0" | "1" = "0" ;
663- let gen : "0" | "1" = "0" ;
664-
665- return new Promise < string | undefined > ( ( resolve ) => {
666- // Use a settled flag so that onDidHide (which always fires) never double-resolves.
667- let settled = false ;
668- const settle = ( value : string | undefined ) => {
669- if ( ! settled ) {
670- settled = true ;
671- resolve ( value ) ;
672- }
673- } ;
674-
675- const quickPick = vscode . window . createQuickPick < PickAdditionsItem > ( ) ;
676- quickPick . title = title ;
677- quickPick . ignoreFocusOut = true ;
678- quickPick . keepScrollPosition = true ;
679- quickPick . matchOnDescription = true ;
680- quickPick . buttons = [
681- ...( canGoBack ? [ vscode . QuickInputButtons . Back ] : [ ] ) ,
682- {
683- iconPath : new vscode . ThemeIcon ( "library" ) ,
684- tooltip : "System" ,
685- location : vscode . QuickInputButtonLocation . Input ,
686- toggle : { checked : false } ,
687- } ,
688- {
689- iconPath : new vscode . ThemeIcon ( "server-process" ) ,
690- tooltip : "Generated" ,
691- location : vscode . QuickInputButtonLocation . Input ,
692- toggle : { checked : false } ,
693- } ,
694- ] ;
695-
696- const getRootItems = ( ) : Promise < void > => {
697- return api
698- . actionQuery ( query , [ "*.cls" , sys , gen ] )
699- . then ( ( data ) => {
700- quickPick . items = data . result . content . map ( ( i ) => sodItemToPickAdditionsItem ( i ) ) ;
701- quickPick . busy = false ;
702- } )
703- . catch ( ( error ) => {
704- quickPick . hide ( ) ;
705- handleError ( error , "Failed to get namespace contents." ) ;
706- } ) ;
707- } ;
708-
709- const expandItem = ( itemIdx : number ) : Promise < void > => {
710- const item = quickPick . items [ itemIdx ] ;
711- // Switch the expand button to a collapse button
712- const newItems = [ ...quickPick . items ] ;
713- newItems [ itemIdx ] = {
714- ...item ,
715- buttons : [ { iconPath : new vscode . ThemeIcon ( "chevron-down" ) , tooltip : "Collapse" } ] ,
716- } ;
717- quickPick . items = newItems ;
718- return api
719- . actionQuery ( query , [ item . fullName + "/*.cls" , sys , gen ] )
720- . then ( ( data ) => {
721- const insertItems : PickAdditionsItem [ ] = data . result . content . map ( ( i ) =>
722- sodItemToPickAdditionsItem ( i , item . fullName , item . label . search ( / \S / ) )
723- ) ;
724- const updatedItems = [ ...quickPick . items ] ;
725- updatedItems . splice ( itemIdx + 1 , 0 , ...insertItems ) ;
726- quickPick . items = updatedItems ;
727- quickPick . busy = false ;
728- } )
729- . catch ( ( error ) => {
730- quickPick . hide ( ) ;
731- handleError ( error , "Failed to get namespace contents." ) ;
732- } ) ;
733- } ;
734-
735- quickPick . onDidTriggerButton ( ( button ) => {
736- if ( button === vscode . QuickInputButtons . Back ) {
737- settle ( undefined ) ; // signal "go back" to the caller
738- quickPick . hide ( ) ;
739- } else {
740- quickPick . busy = true ;
741- if ( button . tooltip == "System" ) {
742- sys = button . toggle . checked ? "1" : "0" ;
743- } else {
744- gen = button . toggle . checked ? "1" : "0" ;
745- }
746- getRootItems ( ) ;
747- }
748- } ) ;
749-
750- quickPick . onDidTriggerItemButton ( ( event ) => {
751- quickPick . busy = true ;
752- const itemIdx = quickPick . items . findIndex ( ( i ) => i . fullName === event . item . fullName ) ;
753- if ( event . button . tooltip . charAt ( 0 ) == "E" ) {
754- expandItem ( itemIdx ) ;
755- } else {
756- // Collapse: remove the button and all descendants
757- const newItems = [ ...quickPick . items ] ;
758- newItems [ itemIdx ] = {
759- ...newItems [ itemIdx ] ,
760- buttons : [ { iconPath : new vscode . ThemeIcon ( "chevron-right" ) , tooltip : "Expand" } ] ,
761- } ;
762- quickPick . items = newItems . filter (
763- ( i , idx ) => idx <= itemIdx || ! i . fullName . startsWith ( event . item . fullName + "." )
764- ) ;
765- quickPick . busy = false ;
766- }
767- } ) ;
768-
769- quickPick . onDidChangeValue ( ( filter : string ) => {
770- // Auto-expand a package when the user types its name followed by a dot
771- if ( filter . endsWith ( "." ) ) {
772- const itemIdx = quickPick . items . findIndex (
773- ( i ) => i . fullName . toLowerCase ( ) === filter . slice ( 0 , - 1 ) . toLowerCase ( )
774- ) ;
775- if (
776- itemIdx != - 1 &&
777- quickPick . items [ itemIdx ] . buttons ?. length &&
778- quickPick . items [ itemIdx ] . buttons [ 0 ] . tooltip . charAt ( 0 ) == "E"
779- ) {
780- quickPick . busy = true ;
781- expandItem ( itemIdx ) ;
782- }
783- }
784- } ) ;
785-
786- quickPick . onDidAccept ( ( ) => {
787- const selected = quickPick . activeItems [ 0 ] ;
788- if ( selected && ! selected . buttons ?. length ) {
789- // Leaf class item (no expand button): strip the .cls extension and resolve
790- const name = selected . fullName . endsWith ( ".cls" ) ? selected . fullName . slice ( 0 , - 4 ) : selected . fullName ;
791- settle ( name ) ;
792- quickPick . hide ( ) ;
793- }
794- } ) ;
795-
796- quickPick . onDidHide ( ( ) => {
797- settle ( "" ) ; // Escape pressed: resolve with "" to signal "skip this optional step"
798- quickPick . dispose ( ) ;
799- } ) ;
800-
801- quickPick . busy = true ;
802- quickPick . show ( ) ;
803- getRootItems ( ) ;
804- } ) ;
805- }
806-
807653export async function modifyProject (
808654 nodeOrUri : NodeBase | vscode . Uri | undefined ,
809655 type : "add" | "remove"
0 commit comments