Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic panel creation (ScriptUI)

Explorer ,
Jun 01, 2018 Jun 01, 2018

Hello fellow scripters !

I'm currently working for a company and i'm struggling onto something and I can't find an answer anywhere (maybe I used some wrong keyword but I did try ! )

This is the current status of my project : The interface below is filled with input fields and dropdown lists. The input is saved has JSON into a selected folder. The problem i'm struggling with is about the Langue panel. This pannel contains some fields and a button made in order to create a new panel named "Lange N(whatever incremented number). The problem is : I need something like an element factory to automaticaly process and add the incremented "Langue N" panel into the empty "Langues Supplémentaire" Panel. I tried to just create a basic element triggered by a onclick function... it did nothing. am I missing something or not ?

Thanks for your time.

code bellow (it might come in handy for some people anyway) EDIT : just don't lose time to ready the ****values variable... it's useless and you're gonna lose some time.

https://i.imgur.com/RRXqscS.png

showDialog();

function showDialog() {

    var unit = null

    var dialog = new Window('dialog', "Fiche Produit");

        dialog.alignChildren = "fill";

    dialog.orientation = "column";

        var groupgen = dialog.add("group",undefined,'');

            groupgen.alignChildren = "fill";

            groupgen.orientation = "row";

    var group1 = groupgen.add("panel",undefined, "Partie 1");

        group1.orentation = "column";

            group1.alignChildren = "fill";

        var group2 = groupgen.add("panel", undefined, "Partie 2");

        group2.alignchildren = "fill";

        group2.orientation = "column";

    var newlanguage = groupgen.add("panel", undefined, "Langues Supplémentaires");

    newlanguage.visible = true

        var produitdesc = group1.add("panel", undefined, "Nom Produit");

                produitdesc.orientation = "column";

                produitdesc.alignChildren = "left";

                produitdesc.margins = [10,17,10,17];

                var nomproduit = produitdesc.add("edittext", undefined, '');

                    nomproduit.orientation = "fill";

                    nomproduit.preferredSize = [250,23];

        var quantity = group1.add("panel", undefined, "Capacity");

                quantity.orientation = "row";

                quantity.alignment = "left";

                quantity.alignChildren = 'center';

                quantity.margins = [10,17,10,17];

                var capacity = quantity.add("edittext", undefined, '');

                        capacity.preferredSize = [250,23];

                var unite = quantity.add("panel", undefined, "Unité");

                        unite.ml = unite.add("radiobutton", undefined, "ml");

                        unite.g = unite.add("radiobutton", undefined, "g");

                        if(unite.ml.value == true)

                        {

                            unit = 'ml';

                        }

                            else if(unite.g ==true)

                            {

                                unit = 'g';

                            }else{

                        unit = "undefined"

                        }

        var articles = group1.add("panel", undefined, "Article");

                articles.orientation = "column";

                articles.alignChildren = "fill";

                articles.margins = [10,17,10,17];

        var articlevalues = ['Aucun', 'Accessoire','Autre','Base','Bidon métal/plastique','Boîtier','Cale','Capot / Capsule','Coque','Etui / Coffret','Flacon','Mécanisme RAL','Notice','Pompe / Compte-goutte','Pot','Sachet','Sleeve','Topette','Tube Aluminium','Tube Plastique','Etiquette Top / Fond','Etiquette Etui','Etiquette Recto','Etiquette Recto-Verso','Etiquette Verso'];

                var article =articles.add("dropdownlist", undefined, articlevalues);

                article.preferredSize = [250,23];

        var categories = group1.add("panel", undefined, "Category");

                categories.orientation = "column";

                categories.alignChildren = "fill";

                categories.margins = [10,17,10,17];

                var Categoryvalue = ['Aucun','Modèle Vente (Retail)','Présérie','Testeur','Taille d\'Essai','Echantillon','Cadeau','Factice','Semi-Fini','Monodose','Technique'];

                var category = categories.add("dropdownlist", undefined, Categoryvalue);

      var SD = group1.add("panel", undefined, "SD");

                 SD.orientation = "column";

                SD.alignChildren = "fill";

                SD.margins = [10,17,10,17];

            var sd = SD.add("edittext", undefined, 'SD');

       var factories = group1.add("panel", undefined, "Factory");

                factories.orientation = "column";

                factories.alignChildren = "fill";

                factories.margins = [10,17,10,17];

            var factoryvalue =  ['Aucun', 'BURGOS', 'SOPROCOS', 'SICAF', 'OMA_EUROPE'];

                var factory = factories.add("dropdownlist",undefined, factoryvalue);

            var acig = group1.add('panel', undefined, 'Code ACI');

                    var aci = acig.add('edittext', undefined,'');

                            aci.preferredSize = [250,23];

            var retail = group1.add("panel", undefined, "Fournisseur");

                    retail.orientation = "column";

                    retail.alignChildren = "fill";

                    retail.margins = [10,17,10,17];

                    var fournisseur = retail.add("edittext", undefined,"");

                            fournisseur.preferredSize = [250,23];

     var Nformula = group1.add("panel", undefined, "Numero de formule");

                  Nformula.orientation = "column";

                 Nformula.alignChildren = "fill";

                 Nformula.margins = [10,17,10,17];

                var nform = Nformula.add("edittext", undefined,'');

                        nform.preferredSize = [250,23];

    var CodeFil = group2.add("panel", undefined, "Code Fil");

                CodeFil.orientation = "column";

                CodeFil.alignChildren = "fill";

                CodeFil.margins = [10,17,10,17];

            var codefiltxt = CodeFil.add("edittext",undefined,'');

                    codefiltxt.preferredSize = [250,23];

    var FormulaType = group2.add("panel", undefined, "Type de formule");

                FormulaType.orientation = "column";

                FormulaType.alignChildren = "fill";

                FormulaType.margins = [10,17,10,17];

            var formulatypevalues = ['Aucun','hair bleaching kit - leader bleaching','hair color kit - leader colorant','hair color kit / hair bleaching kit - developer','hair color kit / hair bleaching kit - post-coloration care / shampoo','hair color kit / hair bleaching kit - pre-coloration care','hair straighteners kit - activator','hair straighteners kit - cream base','hair straighteners kit - reducing agent','hair straighteners kit - setting lotion','kit - other type of component','permanent hair styling kit - activator','permanent hair styling kit - base lotion','permanent hair styling kit - reducing agent','permanent hair styling kit - setting lotion'];

            var formuladrop = FormulaType.add("dropdownlist",undefined, formulatypevalues);

                    formuladrop.preferredSize = [250,23];

                var brands = group2.add("panel", undefined, "Brand");

                        brands.orientation = "column";

                        brands.alignChildren = "fill";

                        brands.margins = [10,17,10,17];

                        var brandvalue = ['Aucun', 'KERASTASE','L\'Oréal Professionnel Paris','SHU UEMURA','MATRIX','PUEROLOGY','REDKEN 5th Avenue NYC','MIZANI'];

                        var brand = brands.add("dropdownlist",undefined, brandvalue);

                        var Subbrand = brands.add("panel", undefined, 'Sub-Brand');

                        var subbrandvalues = ['Aucun', 'Age premium','Fusio-dose','Biotic','Cristalliste','Chronologiste','Densifique','Discipline','Spécifique','Dermo-calm','Homme','Nutritive','Réflexion','Résistance','Soleil','Diarichesse','Dual Stylers by Tecni Art','Holywood Waves by Tecni Art','Wild Stylers by Tecni Art','Infinium','INOA','French Girls by Tecni Art','Play Ball','Pro fiber','Tecni Art','Homme','Majirel','Mythic Oil','Pro Classic','Undercut by tecni Art','Serioxyl','Série Expert','Série Nature','Wet Domination by Tecni Art','Art of Hair','Biolage','Design pulse','Essentials','Total results','Vavoom','Socolor Beauty','Colour Stylist','Cerafill','Chromatics','Texture','Intraforce','Hair Advance','Real Control','For Men','Hairsprays','Volume','Shine Brillance','Style Connection','Volumize','Strength fusion','Pure Force','Guts','HD Resolution','Chromative','Dialight','Root Fusion','Dulcia Advance','Lightmaster','Elixir Ultime','Huile Sublime','Color Sync','Aura Botanica'];

                                var subbrand = Subbrand.add("dropdownlist",undefined, subbrandvalues);

        var Ranges = group2.add("panel", undefined, "Range");

                Ranges.orientation = "column";

                Ranges.alignChildren = "fill";

                Ranges.margins = [10,17,10,17];

                var range = Ranges.add("edittext", undefined, "");

                        range.preferredSize = [250,23];

    var LG= group2.add("panel", undefined, "Langue 1");

                LG.orientation = "column";

                LG.alignChildren = "fill";

                LG.margins = [10,17,10,17];

                LG.preferredSize = [250,23];

            var languagevalues = ['Aucun','GE-generique','BG-bulgarian','BS-bosnian','CS-czech','DA-danish','DE-german','EL-greek','EN-english','ES-spanish','ET-estonian','FI-finnish','FR-french','GA-irish','HR-croatian','HU-hungarian','IT-italian','LT-lithuanian','LV-latvian','NL-dutch','NO-norvegian','MT-maltese','PL-polish','PT-portuguese','RO-romanian','SL-slovenian','SK-slovakian','SR-serbian','SV-swedish','TR-turkish','AR-arabe','UK-ukraine','RU-russie',];

        var langue = LG.add("dropdownlist", undefined, languagevalues);

                    var nomfonc = LG.add("panel",undefined, "Nom Fonctionnel 1");

                    var nomfonction = nomfonc.add("edittext", undefined, '');

                            nomfonction.margins = [10,17,10,17];

                            nomfonction.alignChildren = "fill";

                                nomfonction.preferredSize = [250,23];

                        var vari = LG.add("panel", undefined, 'Variante');

                        var variante = vari.add("edittext", undefined, '');

                        variante.visiblity = false ;

                            variante.margins = [10,17,10,17];

                            variante.alignChildren = "fill";

                            variante.preferredSize = [250,23];

                                

      var newlang = LG.add("button", undefined, "Ajouter une langue");

            variante.visiblity = false ;

;

        var pf = group2.add("panel", undefined, "Code PF");

                pf.orientation = "column";

                pf.alignChildren = "fill";

                pf.margins = [10,17,10,17];

                var codepf = pf.add("edittext", undefined, "");

                        codepf.preferredSize = [250,23];

        var comp = group2.add("panel", undefined, "Type de composant");

                comp.orientation = "column";

                comp.alignChildren = "fill";

                comp.margins = [10,17,10,17];

                var composantvalues = ["Aucun","Primary", "Secondary"];

                var composant = comp.add("dropdownlist", undefined, composantvalues);

                        composant.preferredSize = [250,23];

      var buttonsGroup = dialog.add("group");

            buttonsGroup.alignment = "center";

                var runButton = buttonsGroup.add("button", undefined, "Sauvegarder");

                var cancelButton = buttonsGroup.add("button", undefined, "Annuler");

  newlang.onClick = function(){

  }

    cancelButton.onClick = function() {

        dialog.close(0);

    };

    runButton.onClick = function()

    {

        articlechoice = article.selection.text;

        categorychoice = category.selection.text;

        factorychoice = factory.selection.text;

        formulachoice = formuladrop.selection.text;

        brandchoice = brand.selection.text;

        subbrandchoice = subbrand.selection.text;

        languechoice = langue.selection.text;

        composantchoice = composant.selection.text;

        json = '{"Nom produit" : "'+ nomproduit.text +'","Contenance" :"'+ capacity.text +'",  "Unite de quantite" : "'+ unit+'",  "Article" : "'+ articlechoice+'",  "Categorie" : "'+ categorychoice +'",  "SD" : "'+ sd.text +'",  "Usine" : "'+ factorychoice + '",  "Code ACI" : "'+ aci.text +'",  "Fournisseur" : "'+ fournisseur.text +'",  "Numero de formule" : "'+ nform.text +'",  "Code Fil" : "'+ codefiltxt.text +'",  "Type de formule" : "'+ formulachoice +'",  "Marque" : "'+ brandchoice +'",  "Sous Marque" : "'+ subbrandchoice +'",  "Range" : "'+ range.text + '",  "Langue 1" : "'+ languechoice +'", "Nom Fonctionnel" : "'+ nomfonction.text +'", "Variante" : "'+ vari.text +'",  "Code PF" : "'+ codepf.text +'",  "Type de composant" : "'+ composant.text +'"}'

        jsonDirPath =  Folder.selectDialog( 'Selectionnez le dossier de dépôt de la fiche produit.', '~' );

        var name = nomproduit.text

        file = new File(jsonDirPath + "/" + name + ".json");

        file.remove();

        file.open("w", "TEXT");

        file.lineFeed = "\n";

        file.write(json);

        file.close();

        dialog.close(0)

    }

    dialog.onClose = function() {

    }

    dialog.center();

    dialog.show();

}

TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jun 01, 2018 Jun 01, 2018

In the simplest method I can think of, you can dismiss a dialog and return special instructions to make a new dialog with additional elements. The effect could be a short pause and a blink when the dialogs are switched out.

Other than that, try to do w.layout.layout(true); after you add the element - it may update the window and cause the element to appear!

Translate
Adobe
Valorous Hero ,
Jun 01, 2018 Jun 01, 2018

In the simplest method I can think of, you can dismiss a dialog and return special instructions to make a new dialog with additional elements. The effect could be a short pause and a blink when the dialogs are switched out.

Other than that, try to do w.layout.layout(true); after you add the element - it may update the window and cause the element to appear!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 04, 2018 Jun 04, 2018

First of all thank you Silly-V for your answer !

I'll try both solution right now but ! (there's always a but)

What your telling me to do is  : I click on a button (which is supposed to triger the interface update) and IN the button.onclick function i write down the new elements that I need in the interface ? Could this work ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 04, 2018 Jun 04, 2018

So I tried... It worked EXACTLY as I wanted. So the good answer was (windowvarname).layout.layout(true)

I have one last problem. So as I said earlier I need a Language panel. to be created depending from the users input ( input = 5 means "Language 1", "Language 2", "Language 3", "Language 4", "Language 5" panels. )

I tried doing that

for(i = 1; i> 4; i++){

var language = dialog.add("thing", undefined, "another thing");

}

dialog.layout.layout(true);

This is not working (I thought it might because of the way placed items are identified from the scripting point of view.

And yet I was not able to find anything about it and I can't really find the EXACT keywords I need for this.

Again. THANK YOU Silly-V

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 04, 2018 Jun 04, 2018

Hi,

For complex UI and given the context, you may be interested in looking at CEP panels

Creative Cloud Extension SDK - CC extension resources | Adobe I/O

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 04, 2018 Jun 04, 2018
LATEST

Will do. F

irst I foundwhat I didwrongwiththe identifier

You first need to declare your variable has an array... so :

var langue = [];

langue = panel.add("thingy", undefined, "name of the thingy");

This way it works.

I'm gonna share the element factory I made :

newlang.onClick = function(){

   var LG=[];

   var langue = [];

   var nomfonc = [];

   var nomfonction = [];

   var vari =  [];

   var variante =[];

        i++;

              LG= newlanguage.add("panel", undefined, "Langue "+ i);

                      LG.orientation = "row";

                      LG.alignChildren = "fill";

                      LG.margins = [10,17,10,17];

                      LG.preferredSize = [250,23];

                  var languagevalues = ['Aucun','GE-generique','BG-bulgarian','BS-bosnian','CS-czech','DA-danish','DE-german','EL-greek','EN-english','ES-spanish','ET-estonian','FI-finnish','FR-french','GA-irish','HR-croatian','HU-hungarian','IT-italian','LT-lithuanian','LV-latvian','NL-dutch','NO-norvegian','MT-maltese','PL-polish','PT-portuguese','RO-romanian','SL-slovenian','SK-slovakian','SR-serbian','SV-swedish','TR-turkish','AR-arabe','UK-ukraine','RU-russie',];

           langue = LG.add("dropdownlist", undefined, languagevalues);

                              nomfonc = LG.add("panel",undefined, "Nom Fonctionnel "+i);

                              nomfonction = nomfonc.add("edittext", undefined, '');

                                  nomfonction.margins = [10,17,10,17];

                                  nomfonction.alignChildren = "fill";

                                      nomfonction.preferredSize = [250,23];

                           vari = LG.add("panel", undefined, 'Variante' + i);

                                     variante = vari.add("edittext", undefined, '');

                         variante.visiblity = false ;

                                     variante.margins = [10,17,10,17];

                                     variante.alignChildren = "fill";

                                       variante.preferredSize = [250,23];;

        dialog.layout.layout(true);

  }

This will create a new panel in the target group. this panel will be incremented by I so you will have variable values idfentified by i .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines