<commit_before>/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.opibuilder.converter.writer;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.csstudio.opibuilder.converter.StringSplitter;
import org.csstudio.opibuilder.converter.model.EdmString;
import org.csstudio.opibuilder.converter.model.Edm_activePipClass;

/**
 * XML conversion class for Edm_activePipClass
 * @author <NAME>, <NAME>
 */
public class Opi_activePipClass extends OpiWidget {

    private static Logger log = Logger.getLogger("org.csstudio.opibuilder.converter.writer.Opi_activePipClass");
    private static final String typeId = "linkingContainer";
    private static final String name = "EDM linkingContainer";
    private static final String version = "1.0";

    /**
     * Converts the Edm_activeRectangleClass to OPI Rectangle widget XML.
     */
    public Opi_activePipClass(Context con, Edm_activePipClass r) {
        super(con, r);
        setTypeId(typeId);
        setVersion(version);
        setName(name);


        if(r.getDisplaySource()!=null)
        {
            if(r.getDisplaySource().equals("menu") && r.getDisplayFileName()!=null && r.getFilePv()!=null){

                Map<String, EdmString> displayFileMap = r.getDisplayFileName().getEdmAttributesMap();
                if(displayFileMap.size()>0){

                    Map<String, EdmString> symbolsMap=null;
                    if(r.getSymbols()!=null)
                        symbolsMap = r.getSymbols().getEdmAttributesMap();

                    StringBuilder sb = new StringBuilder("importPackage(Packages.org.csstudio.opibuilder.scriptUtil);\n");
                    sb.append("var pv0 = PVUtil.getLong(pvs[0]);\n");
                    boolean f= false;
                    for(String key : displayFileMap.keySet()){
                        if(f)
                            sb.append("else ");
                        f=true;
                        sb.append("if(pv0=="+key+"){\n");
                        boolean append = true;
                        if(r.getReplaceSymbols()!=null&&r.getReplaceSymbols().getEdmAttributesMap().containsKey(key)){
                            append = !r.getReplaceSymbols().getEdmAttributesMap().get(key).is();
                        }
                        sb.append("var macroInput = DataUtil.createMacrosInput("+append+");\n");
                        if(symbolsMap != null && symbolsMap.containsKey(key)){
                            try {
                                EdmString symbols = symbolsMap.get(key);
                                if (symbols != null) {
                                    for (String s : StringSplitter.splitIgnoreInQuotes(symbols.get(), ',', true)) {
                                        String[] rs = StringSplitter.splitIgnoreInQuotes(s, '=', true);
                                        if (rs.length == 2) {
                                            // EDM treats '' as an empty string.
                                            rs[1] = rs[1].equals("''") ? "" : rs[1];
                                            try {
                                                sb.append("macroInput.put(\"" + rs[0] + "\", \"" + rs[1]+"\");\n");
                                            } catch (Exception e) {
                                                log.log(Level.WARNING, "Parse Macros Error on: " + s, e);
                                            }
                                        }
                                    }
                                }
                            } catch (Exception e) {
                                log.log(Level.WARNING, "Parse Macros Error ", e);
                            }
                        }
                        sb.append("widget.setPropertyValue(\"macros\", macroInput);\n");

                        sb.append("widget.setPropertyValue(\"opi_file\",\""+
                                convertFileExtention(displayFileMap.get(key).get()) +"\");\n");

                        sb.append("}\n");
                    }

                    LinkedHashMap<String, Boolean> pvNames = new LinkedHashMap<String, Boolean>();
                    pvNames.put(convertPVName(r.getFilePv()), true);

                    new OpiScript(widgetContext, "OPIFileScript", pvNames , sb.toString());
                }




            }else if (r.getFile() != null) {
                String originPath = r.getFile();
                originPath = convertFileExtention(originPath);
                new OpiString(widgetContext, "opi_file", originPath);
            }
        }

        if(r.getDisplaySource()==null && r.getFilePv()!=null){
            createPVOutputRule(r, convertPVName(r.getFilePv()), "opi_file", "pvStr0", "OPIFileFromPVRule");
        }

        new OpiString(widgetContext, "resize_behaviour", "2");

        log.config("Edm_activePipClass written.");

    }



}
<commit_msg>EDM converter: embedded windows have no border.<commit_after>/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.opibuilder.converter.writer;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.csstudio.opibuilder.converter.StringSplitter;
import org.csstudio.opibuilder.converter.model.EdmString;
import org.csstudio.opibuilder.converter.model.Edm_activePipClass;

/**
 * XML conversion class for Edm_activePipClass
 * @author <NAME>, <NAME>
 */
public class Opi_activePipClass extends OpiWidget {

    private static Logger log = Logger.getLogger("org.csstudio.opibuilder.converter.writer.Opi_activePipClass");
    private static final String typeId = "linkingContainer";
    private static final String name = "EDM linkingContainer";
    private static final String version = "1.0";

    /**
     * Converts the Edm_activeRectangleClass to OPI Rectangle widget XML.
     */
    public Opi_activePipClass(Context con, Edm_activePipClass r) {
        super(con, r);
        setTypeId(typeId);
        setVersion(version);
        setName(name);


        if(r.getDisplaySource()!=null)
        {
            if(r.getDisplaySource().equals("menu") && r.getDisplayFileName()!=null && r.getFilePv()!=null){

                Map<String, EdmString> displayFileMap = r.getDisplayFileName().getEdmAttributesMap();
                if(displayFileMap.size()>0){

                    Map<String, EdmString> symbolsMap=null;
                    if(r.getSymbols()!=null)
                        symbolsMap = r.getSymbols().getEdmAttributesMap();

                    StringBuilder sb = new StringBuilder("importPackage(Packages.org.csstudio.opibuilder.scriptUtil);\n");
                    sb.append("var pv0 = PVUtil.getLong(pvs[0]);\n");
                    boolean f= false;
                    for(String key : displayFileMap.keySet()){
                        if(f)
                            sb.append("else ");
                        f=true;
                        sb.append("if(pv0=="+key+"){\n");
                        boolean append = true;
                        if(r.getReplaceSymbols()!=null&&r.getReplaceSymbols().getEdmAttributesMap().containsKey(key)){
                            append = !r.getReplaceSymbols().getEdmAttributesMap().get(key).is();
                        }
                        sb.append("var macroInput = DataUtil.createMacrosInput("+append+");\n");
                        if(symbolsMap != null && symbolsMap.containsKey(key)){
                            try {
                                EdmString symbols = symbolsMap.get(key);
                                if (symbols != null) {
                                    for (String s : StringSplitter.splitIgnoreInQuotes(symbols.get(), ',', true)) {
                                        String[] rs = StringSplitter.splitIgnoreInQuotes(s, '=', true);
                                        if (rs.length == 2) {
                                            // EDM treats '' as an empty string.
                                            rs[1] = rs[1].equals("''") ? "" : rs[1];
                                            try {
                                                sb.append("macroInput.put(\"" + rs[0] + "\", \"" + rs[1]+"\");\n");
                                            } catch (Exception e) {
                                                log.log(Level.WARNING, "Parse Macros Error on: " + s, e);
                                            }
                                        }
                                    }
                                }
                            } catch (Exception e) {
                                log.log(Level.WARNING, "Parse Macros Error ", e);
                            }
                        }
                        sb.append("widget.setPropertyValue(\"macros\", macroInput);\n");

                        sb.append("widget.setPropertyValue(\"opi_file\",\""+
                                convertFileExtention(displayFileMap.get(key).get()) +"\");\n");

                        sb.append("}\n");
                    }

                    LinkedHashMap<String, Boolean> pvNames = new LinkedHashMap<String, Boolean>();
                    pvNames.put(convertPVName(r.getFilePv()), true);

                    new OpiScript(widgetContext, "OPIFileScript", pvNames , sb.toString());
                }




            }else if (r.getFile() != null) {
                String originPath = r.getFile();
                originPath = convertFileExtention(originPath);
                new OpiString(widgetContext, "opi_file", originPath);
            }
        }

        if(r.getDisplaySource()==null && r.getFilePv()!=null){
            createPVOutputRule(r, convertPVName(r.getFilePv()), "opi_file", "pvStr0", "OPIFileFromPVRule");
        }

        new OpiString(widgetContext, "resize_behaviour", "2");

        // No border in EDM embedded window.
        new OpiInt(widgetContext, "border_style", 0);

        log.config("Edm_activePipClass written.");

    }



}

{'fraction_non_alphanumeric': 0.14366557137641475, 'fraction_numerical': 0.004107338444687842, 'mean_word_length': 1.5970609149087462, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3409782', 'n_tokens_mistral': 2846, 'n_tokens_neox': 2692, 'n_words': 512}