Ignore:
Timestamp:
09/11/12 12:22:59 (12 years ago)
Author:
magsj467
Message:

First version of Graphical Dependency-Browser thesis work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.omc/src/org/modelica/mdt/omc/OMCProxy.java

    r1577 r1643  
    7777import org.modelica.mdt.core.ListElement;
    7878import org.modelica.mdt.core.ModelicaParserException;
     79import org.modelica.mdt.core.compiler.ComponentParser;
    7980import org.modelica.mdt.core.compiler.IClassInfo;
    8081import org.modelica.mdt.core.compiler.ConnectException;
     
    806807    public ParseResults loadSourceFile(IFile file) throws ConnectException, UnexpectedReplyException
    807808    {
     809
     810        //System.out.println("Look at this: " + file.getName());
    808811        synchronized (getLazyLoadList())
    809812        {                       
     
    832835        /* Always keep your stuff nice and tidy! */
    833836        retval = retval.trim();
    834 
    835837        String errorString = ret.getError();
    836838
     
    14271429    }
    14281430   
    1429    
     1431    /*
     1432     * Extended by Magnus Sjöstrand
     1433     *
     1434     */
     1435   
     1436    /**
     1437     * gets the nth inheritance to the given class
     1438     * 
     1439     * @throws ConnectException if we're unable to start communicating with
     1440     * the server
     1441     */
     1442   
     1443    public ICompilerResult getNthInheritedClass(String className, int n) throws ConnectException, UnexpectedReplyException {
     1444        ICompilerResult res = sendExpression("getNthInheritedClass("+ className + ", " + n + ")", true);
     1445        res.trimFirstResult();
     1446
     1447        return res;
     1448    }
     1449   
     1450    /**
     1451     * gets the number of inheritances to the given class
     1452     * 
     1453     * @throws ConnectException if we're unable to start communicating with
     1454     * the server
     1455     */
     1456   
     1457    public int getInheritanceCount(String className) throws ConnectException, UnexpectedReplyException {
     1458        int resNum = 0;
     1459        ICompilerResult res = sendExpression("getInheritanceCount(" + className + ")", true);
     1460        res.trimFirstResult();               
     1461        if(!res.getFirstResult().isEmpty()){
     1462            resNum = Integer.parseInt(res.getFirstResult());
     1463        }
     1464        return resNum;
     1465    }
     1466   
     1467    /**
     1468     * gets the nth algorithm in the given class
     1469     * 
     1470     * @throws ConnectException if we're unable to start communicating with
     1471     * the server
     1472     */
     1473   
     1474    public ICompilerResult getNthAlgorithmItem(String className, int n) throws ConnectException, UnexpectedReplyException {
     1475        ICompilerResult res = sendExpression("getNthAlgorithmItem("+ className + ", " + n + ")", true);
     1476        res.trimFirstResult();
     1477
     1478        return res;
     1479    }
     1480   
     1481    /**
     1482     * gets the number of algorithms in the given class
     1483     * 
     1484     * @throws ConnectException if we're unable to start communicating with
     1485     * the server
     1486     */
     1487       
     1488       public int getAlgorithmItemsCount(String className) throws ConnectException, UnexpectedReplyException {
     1489        int resNum = 0;
     1490        ICompilerResult res = sendExpression("getAlgorithmItemsCount(" + className + ")", true);
     1491        res.trimFirstResult();               
     1492        if(!res.getFirstResult().isEmpty()){
     1493            resNum = Integer.parseInt(res.getFirstResult());
     1494        }
     1495        return resNum;
     1496    }
     1497   
     1498    /**
     1499     * gets the nth equation in the given class
     1500     * 
     1501     * @throws ConnectException if we're unable to start communicating with
     1502     * the server
     1503     */
     1504   
     1505    public ICompilerResult getNthEquationItem(String className, int n) throws ConnectException, UnexpectedReplyException {
     1506        ICompilerResult res = sendExpression("getNthEquationItem("+ className + ", " + n + ")", true);
     1507        res.trimFirstResult();
     1508
     1509        return res;
     1510    }
     1511   
     1512    /**
     1513     * gets the number of equations to the given class
     1514     * 
     1515     * @throws ConnectException if we're unable to start communicating with
     1516     * the server
     1517     */
     1518       
     1519       public int getEquationItemsCount(String className) throws ConnectException, UnexpectedReplyException {
     1520        int resNum = 0;
     1521        ICompilerResult res = sendExpression("getEquationItemsCount(" + className + ")", true);
     1522        res.trimFirstResult();               
     1523        if(!res.getFirstResult().isEmpty()){
     1524            resNum = Integer.parseInt(res.getFirstResult());
     1525        }
     1526        return resNum;
     1527    }
     1528   
     1529    /**
     1530     * lists all of the components in class
     1531     * 
     1532     * @throws ConnectException if we're unable to start communicating with
     1533     * the server
     1534     */
     1535   
     1536    public List getComponents(String className) throws ConnectException, UnexpectedReplyException {
     1537        ICompilerResult res = sendExpression("getComponents("+ className +")", true);
     1538        //System.out.println(res.getFirstResult());
     1539        List list = null;
     1540        try{
     1541            list = ComponentParser.parseList(res.getFirstResult());
     1542        }
     1543        catch(ModelicaParserException e){
     1544            throw new UnexpectedReplyException("Unable to parse list: "
     1545                    + e.getMessage());
     1546        }
     1547        return list;
     1548    }
     1549   
     1550    public boolean classExist(String className) throws ConnectException, UnexpectedReplyException {
     1551        ICompilerResult res = sendExpression("classExist("+ className +")", true);
     1552        if (res.getFirstResult().toString().equals("true")){
     1553                return true;
     1554        }
     1555        return false;
     1556    }
     1557   
     1558    public ICompilerResult getErrorString() throws ConnectException, UnexpectedReplyException {
     1559        ICompilerResult res = sendExpression("getErrorString()", true);
     1560        return res;
     1561    }
     1562   
     1563    public ICompilerResult loadFile(String classPath) throws ConnectException, UnexpectedReplyException {
     1564        classPath = classPath.replace("\\", "/");
     1565        ICompilerResult res = sendExpression("loadFile(\""+ classPath +"\")", true);
     1566        return res;
     1567    }
    14301568}
Note: See TracChangeset for help on using the changeset viewer.