Changeset 9977

Show
Ignore:
Timestamp:
04/05/10 11:42:39 (3 years ago)
Author:
deepan
Message:

Added Python component generation support; Updated OEF to hide unsupported property types;

Location:
ossiedev/trunk/tools/OEF/src/edu/vt/ossie
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/trunk/tools/OEF/src/edu/vt/ossie/actionSets/GenerateComponent.java

    r8301 r9977  
    2626import edu.vt.ossie.editors.ComponentEditor; 
    2727import edu.vt.ossie.wavedev.Component; 
     28import edu.vt.ossie.wavedev.Property; 
     29import edu.vt.ossie.wavedev.SimpleProperty;; 
    2830 
    2931//------------------------------------------------------------------------- 
     
    5052            "Generate invoked on editor " + componentEditor.getComponent()); 
    5153        IPath targetDir = getProject().getLocation(); 
    52  
     54        //log.debug("targetDir is " + targetDir.toOSString()); 
     55         
    5356        // remember old files 
    5457        File projectDir = targetDir.toFile(); 
     
    6871 
    6972        Component component = componentEditor.getComponent(); 
     73        log.debug("Component template is " + component.getTemplate()); 
     74        if (component.getTemplate().equals("py_comp")) { 
     75                /* 
     76                 * Python components supports only the following data types 
     77                 * short, ushort, float and double 
     78                 * Watch out for readWriteProps() function in wavedev/generate/templates/py_comp/genStructure.py 
     79                 * for any changes to additional datatype supported 
     80                 */ 
     81                Property[] cProps = component.getPropertiesAsArray(); 
     82                for (Property prp : cProps){ 
     83                        String pType = ((SimpleProperty)prp).getType(); 
     84                        if (pType.equals("short") || 
     85                                        pType.equals("int") || 
     86                                        pType.equals("float") || 
     87                                        pType.equals("double")){ 
     88                                continue; 
     89                        } 
     90                        else{ 
     91                                MessageDialog.openError(componentEditor.getSite().getShell(), 
     92                                                "Invalid data types for properties", 
     93                                                "Property \"" + prp.getName() + "\" is set to datatype \"" + pType + "\"." 
     94                                                + "Python components supports only short/int/float/double" ); 
     95                                                 
     96                                log.debug("data types unsupported for prop " + prp.getName() + " of python component"); 
     97                                return; 
     98                        } 
     99                } 
     100                 
     101        } 
     102         
    70103        boolean previouslyGenerated = false; 
     104        log.debug("targetDir is " + targetDir.toOSString()); 
    71105        if (targetDir.lastSegment().equals(component.getName())) 
    72106        { 
    73107            targetDir = targetDir.removeLastSegments(1); 
     108            log.debug("projectDir is " + projectDir.toString()); 
    74109            previouslyGenerated = 
    75110                (new File(projectDir, component.getName() + ".cpp")).exists() 
     
    86121                componentEditor.getSite().getShell(), 
    87122                "Generated Files Already Exist", 
    88                 "Skeleton implementation files for this component have " 
     123                "Skeleton implementation files for " + component.getName() + "component have " 
    89124                + "already been generated.  If you regenerate the skeleton " 
    90125                + "files again, any changes in the existing files will be " 
     
    258293    private IProject getProject() 
    259294    { 
    260         if (project == null 
    261             && componentEditor != null 
     295        if (project == null) 
     296                        log.debug("getProject(): project is null"); 
     297        if (componentEditor != null 
    262298            && componentEditor.isConnectedToFile()) 
    263299        { 
     300                //log.debug("getProject(): " + componentEditor.getFileInput().getFile().getName()); 
    264301            project = componentEditor.getFileInput().getFile().getProject(); 
    265302        } 
  • ossiedev/trunk/tools/OEF/src/edu/vt/ossie/dialogs/PropertiesDialog.java

    r7926 r9977  
    326326     
    327327    //string arrays to hold combo box choices 
    328     private String[] typeChoices = {"boolean", "char", "double", 
    329         "float", "short", "long", "objref", "octet", "string", "ulong", 
    330         "ushort"}; 
     328    /* Removing char, objref, octet and string types */ 
     329    /* re-include when the component is able to compile and build  
     330     * without errors for these datatypes 
     331     */ 
     332    private String[] typeChoices = {"boolean", "double", 
     333        "float", "short", "long", "ulong", "ushort"}; 
     334     //"objref", "octet", "string", "char" 
    331335    private String[] modeChoices = {"readonly", "readwrite", 
    332336        "writeonly"}; 
  • ossiedev/trunk/tools/OEF/src/edu/vt/ossie/editors/ComponentEditor.java

    r8299 r9977  
    680680                        result = ((SimpleSequenceProperty)element).getDefaultValues().toString(); 
    681681                    } 
     682                    log.debug("result: " + result); 
    682683                    return result; 
    683684                } 
     
    763764                component.removeProperty(property[0].getText(0)); 
    764765                tableViewer.setInput(component); 
     766                tableViewer.refresh(); 
    765767            } 
    766768 
     
    978980        { 
    979981            doSetInput(input); 
     982            log.debug("setInputWithNotify: " + input.getName() ); 
    980983 
    981984            /* 
  • ossiedev/trunk/tools/OEF/src/edu/vt/ossie/editors/OWDEditor.java

    r8551 r9977  
    355355                            log.debug("Refreshing resources tree"); 
    356356                            monitor.worked(1); 
    357                             final PyWrapper[] result = wavedevFactory() 
    358                                 .toArrayOfWrappedElements( 
    359                                     mainFrame().loadResources()); 
     357                            final PyWrapper[] result = wavedevFactory().toArrayOfWrappedElements(mainFrame().loadResources()); 
    360358                            monitor.worked(8); 
    361359 
     
    16531651        public void run() 
    16541652        { 
    1655             getActiveWaveform().addNewComponent((Component)subject, null); 
     1653                Waveform tempWform = getActiveWaveform(); 
     1654                log.debug("AddToWaveformAction(): Wform is " + tempWform.getName()); 
     1655                log.debug("AddToWAveformAction(): Wform class is " + tempWform.getClass()); 
     1656                try { 
     1657                        getActiveWaveform().addNewComponent((Component)subject, null); 
     1658                } 
     1659                catch(Exception e){ 
     1660                        log.debug(e.fillInStackTrace()); 
     1661                } 
    16561662            refreshWaveform(); 
    16571663            setIsDirty(true); 
  • ossiedev/trunk/tools/OEF/src/edu/vt/ossie/wavedev/Component.java

    r7802 r9977  
    425425    } 
    426426     
     427    public String getTemplate() 
     428    { 
     429        try { 
     430                String temp = getString(ECLIPSE_TEMPLATE); 
     431                return temp; 
     432        } 
     433        catch(Error e){ 
     434                System.out.println("No xTemplate attribute. adding a new one with basic_ports as def value"); 
     435                put(ECLIPSE_TEMPLATE, "basic_ports"); 
     436                return getString(ECLIPSE_TEMPLATE); 
     437        } 
     438    } 
     439     
    427440  
    428441    public void removePort(String portName) 
     
    483496        { 
    484497            put(ECLIPSE_ASSIGNED_COMPONENTS, new PyList()); 
    485  
     498            put(ECLIPSE_TEMPLATE, "basic_ports"); 
    486499            ensurePortsAreParented(); 
    487500            // Can't call ensurePortsKnowAboutConnections(), since other 
  • ossiedev/trunk/tools/OEF/src/edu/vt/ossie/wavedev/SimpleProperty.java

    r9385 r9977  
    7676            try 
    7777        { 
    78             put(VALUE, Integer.parseInt(defaultValue)); 
     78            put(DEFAULT_VALUE, Integer.parseInt(defaultValue)); 
    7979        } 
    8080        catch(NumberFormatException nfe) 
     
    8282            try 
    8383            { 
    84                 put(VALUE, Long.parseLong(defaultValue)); 
     84                put(DEFAULT_VALUE, Long.parseLong(defaultValue)); 
    8585            } 
    8686            catch(NumberFormatException nfe2) 
    8787            { 
    88                 put(VALUE, Double.parseDouble(defaultValue)); 
     88                put(DEFAULT_VALUE, Double.parseDouble(defaultValue)); 
    8989            } 
    9090        }