Example usage for java.lang ClassNotFoundException printStackTrace

List of usage examples for java.lang ClassNotFoundException printStackTrace

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:GraphingProject.TheJApplet.java

/**
 * Initializes the applet TheJApplet/*from ww w .  j  a va2 s .  co  m*/
 */
@Override
public void init() {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(TheJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(TheJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(TheJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(TheJApplet.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>

    /* Create and display the applet */
    try {
        java.awt.EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                initComponents();
            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:org.beepcore.beep.example.Beepd.java

/**
 * Parses the beepd element in the configuration file and loads the
 * classes for the specified profiles.// w  w w. java  2  s.  co  m
 *
 * @param serverConfig &ltbeepd&gt configuration element.
 */
private Beepd(Element serverConfig) throws Exception {
    reg = new ProfileRegistry();

    if (serverConfig.hasAttribute("port") == false) {
        throw new Exception("Invalid configuration, no port specified");
    }

    port = Integer.parseInt(serverConfig.getAttribute("port"));

    // Parse the list of profile elements.
    NodeList profiles = serverConfig.getElementsByTagName("profile");
    for (int i = 0; i < profiles.getLength(); ++i) {
        if (profiles.item(i).getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        Element profile = (Element) profiles.item(i);

        if (profile.getNodeName().equalsIgnoreCase("profile") == false) {
            continue;
        }

        String uri;
        String className;
        String requiredProperites;
        String tuningProperties;

        if (profile.hasAttribute("uri") == false) {
            throw new Exception("Invalid configuration, no uri specified");
        }

        uri = profile.getAttribute("uri");

        if (profile.hasAttribute("class") == false) {
            throw new Exception("Invalid configuration, no class " + "specified for profile " + uri);
        }

        className = profile.getAttribute("class");

        // parse the parameter elements into a ProfileConfiguration
        ProfileConfiguration profileConfig = parseProfileConfig(profile.getElementsByTagName("parameter"));

        // load the profile class
        Profile p;
        try {
            p = (Profile) Class.forName(className).newInstance();
        } catch (ClassNotFoundException e) {
            throw new Exception("Class " + className + " not found");
        } catch (ClassCastException e) {
            throw new Exception("class " + className + " does not " + "implement the "
                    + "org.beepcore.beep.profile.Profile " + "interface");
        }

        SessionTuningProperties tuning = null;

        if (profile.hasAttribute("tuning")) {
            String tuningString = profile.getAttribute("tuning");
            Hashtable hash = new Hashtable();
            StringTokenizer tokens = new StringTokenizer(tuningString, ":=");

            try {
                while (tokens.hasMoreTokens()) {
                    String parameter = tokens.nextToken();
                    String value = tokens.nextToken();

                    hash.put(parameter, value);
                }
            } catch (NoSuchElementException e) {
                e.printStackTrace();

                throw new Exception("Error parsing tuning property on " + "profile " + uri);
            }

            tuning = new SessionTuningProperties(hash);
        }

        // Initialize the profile and add it to the advertised profiles
        reg.addStartChannelListener(uri, p.init(uri, profileConfig), tuning);
    }
}

From source file:org.alinous.plugin.mysql.MySQLDataSource.java

public void init(AlinousCore core) throws DataSourceException {
    this.logger = core.getLogger();

    try {// ww w  .ja  va  2 s  .c  o m
        this.driver = MySQLDriverSingleton.getDriver(core);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw new DataSourceException(e);
    } catch (InstantiationException e) {
        throw new DataSourceException(e);
    } catch (IllegalAccessException e) {
        throw new DataSourceException(e);
    } catch (Throwable e) {
        throw new DataSourceException(e);
    }

    this.factory = new MySQLConnectionFactory(this.driver, this.user, this.pass, this.uri);
    this.connectionPool = new GenericObjectPool(this.factory);
    this.connectionPool.setMaxActive(32);
    this.connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
    this.connectionPool.setTestOnBorrow(true);
    this.connectionPool.setMinEvictableIdleTimeMillis(1000 * 60 * 5);

    this.typeHelper = new TypeHelper(this);

    this.core = core;
}

From source file:Connexion.ChartMutuelle.java

public ChartMutuelle() {

    try {//from  ww  w  .  j  av  a  2  s. c o m
        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
        /* Grer les ventuelles erreurs ici. */
    }
    int ag2r = 0;
    int ccvrp = 0;
    int cnamts = 0;
    int lmde = 0;
    int maaf = 0;
    int mas = 0;
    int mgen = 0;
    int mgsp = 0;
    int mma = 0;
    int mnam = 0;
    int mnftc = 0;
    int mnh = 0;
    try {
        ResultSet resultat1 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'AG2R'");
        // on rcupre le nombre de lignes de la requte
        if (resultat1.last()) {
            ag2r = resultat1.getRow();
        }
        System.out.println(ag2r);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    try {
        ResultSet resultat2 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'CCVRP'");
        // on rcupre le nombre de lignes de la requte
        if (resultat2.last()) {
            ccvrp = resultat2.getRow();
        }
        System.out.println(ccvrp);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    try {

        ResultSet resultat3 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'CNAMTS'");
        // on rcupre le nombre de lignes de la requte
        if (resultat3.last()) {
            cnamts = resultat3.getRow();
        }
        System.out.println(cnamts);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    try {

        ResultSet resultat4 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'LMDE'");
        // on rcupre le nombre de lignes de la requte
        if (resultat4.last()) {
            lmde = resultat4.getRow();
        }
        System.out.println(lmde);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    try {

        ResultSet resultat5 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MAAF'");
        // on rcupre le nombre de lignes de la requte
        if (resultat5.last()) {
            maaf = resultat5.getRow();
        }
        System.out.println(maaf);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    try {

        ResultSet resultat6 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MAS'");
        // on rcupre le nombre de lignes de la requte
        if (resultat6.last()) {
            mas = resultat6.getRow();
        }
        System.out.println(mas);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    try {
        ResultSet resultat7 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MGEN'");
        // on rcupre le nombre de lignes de la requte
        if (resultat7.last()) {
            mgen = resultat7.getRow();
        }
        System.out.println(mgen);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    try {
        ResultSet resultat8 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MGSP'");
        // on rcupre le nombre de lignes de la requte
        if (resultat8.last()) {
            mgsp = resultat8.getRow();
        }
        System.out.println(mgsp);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    try {

        ResultSet resultat9 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MMA'");
        // on rcupre le nombre de lignes de la requte
        if (resultat9.last()) {
            mma = resultat9.getRow();
        }
        System.out.println(mma);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    try {

        ResultSet resultat10 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MNAM'");
        // on rcupre le nombre de lignes de la requte
        if (resultat10.last()) {
            mnam = resultat10.getRow();
        }
        System.out.println(mnam);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    try {

        ResultSet resultat11 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MNFTC'");
        // on rcupre le nombre de lignes de la requte
        if (resultat11.last()) {
            mnftc = resultat11.getRow();
        }
        System.out.println(mnftc);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    try {

        ResultSet resultat12 = this.connect
                .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)
                .executeQuery("SELECT mutuelle FROM malade WHERE mutuelle =  'MNH'");
        // on rcupre le nombre de lignes de la requte
        if (resultat12.last()) {
            mnh = resultat12.getRow();
        }
        System.out.println(mnh);

    } catch (SQLException e) {
        e.printStackTrace();
    }
    DefaultPieDataset union = new DefaultPieDataset();

    //remplir l'ensemble

    union.setValue("AG2R", ag2r);
    union.setValue("CCVRP", ccvrp);
    union.setValue("CNAMTS", cnamts);
    union.setValue("LMDE", lmde);
    union.setValue("MAAD", maaf);
    union.setValue("MAS", mas);
    union.setValue("MGEN", mgen);
    union.setValue("MGSP", mgsp);
    union.setValue("MMA", mma);
    union.setValue("MNAM", mnam);
    union.setValue("MNFTC", mnftc);
    union.setValue("MNH", mnh);

    JFreeChart repart = ChartFactory.createPieChart3D("Nombre de malades par mutuelle", union, true, true,
            false);
    ChartPanel crepart = new ChartPanel(repart);
    this.add(crepart);
    this.pack();
    this.setVisible(true);
}

From source file:gov.nih.nci.system.web.struts.action.RestQuery.java

/**
 * Generates an HTML Document for a given XML document
 *
 * @param doc/*w w  w  .  j a v  a  2 s  . c  o m*/
 *            Specifies the XML document
 * @param className
 *            Resulting class names
 * @param queryStr
 *            Query string used for the query
 * @param roleName
 *            role name in the query, if used
 * @return String
 *            HTML string
 * @throws Exception
 */
protected String getHTML(Document doc, String className, String queryStr, String roleName) throws Exception {
    try {
        StringBuffer buffer = new StringBuffer();
        Map<String, String> header = new HashMap<String, String>();
        Map<String, List<String>> body = new HashMap<String, List<String>>();
        //Main table
        buffer.append(
                "<table border=\"0\" bordercolor=\"orange\" summary=\"\" cellpadding=\"0\" cellspacing=\"0\">");
        buffer.append("<tr>");
        buffer.append("<td class=\"dataTablePrimaryLabel\" height=\"20\" align=\"left\">");
        String criteria = null;

        if (queryStr != null && queryStr.indexOf("search;") != -1)
            criteria = queryStr.substring(queryStr.indexOf("search;") + 7, queryStr.length());
        else
            criteria = queryStr;
        //Criteria value to display
        buffer.append("Criteria: " + org.apache.commons.lang.StringEscapeUtils.escapeHtml(criteria));
        buffer.append("<br />");
        Element root = doc.getRootElement();
        //If resulted XML is a response, capture the message to display
        if (root.getName().equals("response")) {
            buffer.append(getResponseHTML(root, className));
        } else {
            String classEleName = className;

            //Get resulted class name
            if (selectedSearchDomain != null && !selectedSearchDomain.equals("Please choose")) {
                if (!selectedSearchDomain.equalsIgnoreCase(className)) {
                    classEleName = selectedSearchDomain;
                }
            }
            //If role name used
            if (roleName != null) {
                classEleName = getTargetClassName(className, roleName);
            }

            buffer.append("Result Class: " + classEleName);
            buffer.append("</td>");
            buffer.append("</tr>");
            //Get Id column. This will be used to display Id column first in the results table
            String idCol = null;
            String idColValue = null;
            try {
                idCol = classCache.getClassIdName(Class.forName(classEleName));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

            buffer.append(getPagingLinks(root));

            buffer.append("<tr>");
            buffer.append("<td>");
            buffer.append(
                    "<table summary=\"Data Summary\" cellpadding=\"3\" cellspacing=\"0\" border=\"0\" class=\"dataTable\" width=\"100%\">");

            //For each sub element to the root:
            //if it is link, skip it. This is link elements for collections representing paging, self
            List<Element> tableRows = root.getChildren();
            List columns = new ArrayList();
            for (Element child : tableRows) {
                StringBuffer headerBuffer = new StringBuffer();
                StringBuffer bodyBuffer = new StringBuffer();

                String childName = classEleName.substring(classEleName.lastIndexOf(".") + 1,
                        classEleName.length());

                if (child.getName().equals("link"))
                    continue;

                //Get element class name. There could be different classes in the given XML
                //representing inheritance
                String fullClassName = classCache.getPkgNameForClass(child.getName()) + "." + child.getName();

                headerBuffer.append("<tr>");
                bodyBuffer.append("<tr>");

                Class klass = classCache.getClassFromCache(fullClassName);
                Field[] fields = classCache.getAllFields(klass);
                //Arrays.sort(fields);

                //Get links for child element and add link ref name to list
                List<String> refNameList = new ArrayList();
                List<String> assocNames = classCache.getAssociations(fullClassName);
                for (String assocName : assocNames) {
                    boolean foundLink = false;
                    if (assocName.indexOf("(") == -1)
                        continue;
                    else {
                        refNameList.add(assocName.substring(0, assocName.indexOf("(")).trim());
                    }
                }

                refNameList.add("self");
                String idColName = classCache.getClassIdName(klass);
                // Add id column to the table first
                for (int i = 0; i < fields.length; i++) {
                    boolean headerAdded = false;
                    Field field = fields[i];
                    if (!field.getName().equals(idColName))
                        continue;

                    bodyBuffer.append("<td class=\"dataCellText\" nowrap=\"off\">");

                    if (metadata) {
                        MetadataElement mdata = MetadataCache.getInstance()
                                .getMetadata(caDSRMetadata.CONTEXT_NAME, fullClassName, idColName);
                        //System.out.println("mdata "+mdata);
                        if (mdata != null) {
                            Element attrEle = child.getChild(idColName, child.getNamespace());
                            if (attrEle != null) {
                                bodyBuffer.append(org.apache.commons.lang.StringEscapeUtils
                                        .escapeHtml(attrEle.getValue()));
                                idColValue = attrEle.getValue();
                                headerBuffer.append(
                                        "<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                                headerBuffer.append(
                                        "<a href=\"javascript:showMetadata(" + caDSRMetadata.CONTEXT_NAME + ","
                                                + fullClassName + "," + idColName + ")\">");
                                headerBuffer.append(idColName);
                                headerBuffer.append("</a>");
                                headerBuffer.append("</th>");
                                headerAdded = true;
                            }

                        } else {
                            Attribute attr = child.getAttribute(idColName);
                            if (attr != null) {
                                bodyBuffer.append(
                                        org.apache.commons.lang.StringEscapeUtils.escapeHtml(attr.getValue()));
                                idColValue = attr.getValue();
                            }
                        }
                    } else {
                        Attribute attr = child.getAttribute(idColName);
                        if (attr != null) {
                            bodyBuffer.append(
                                    org.apache.commons.lang.StringEscapeUtils.escapeHtml(attr.getValue()));
                            idColValue = attr.getValue();
                        }
                    }

                    if (!headerAdded) {
                        headerBuffer.append("<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                        headerBuffer.append(idColName);
                        headerBuffer.append("</th>");
                    }
                    if (field.getType().getName().startsWith(isoprefix)) {
                        Element childElement = getChild(child, field.getName(), true);
                        if (childElement == null)
                            bodyBuffer.append("&nbsp;");
                        else {
                            bodyBuffer.append(
                                    "<table cellpadding=\"0\" cellspacing=\"2\" width=\"100%\" border=\"0\">");
                            bodyBuffer.append("<tbody><tr class=\"dataRowLight\">");
                            bodyBuffer.append("<td class=\"isoDataCellText\" nowrap=\"off\">");
                            bodyBuffer.append(formatISOElement(childElement));
                            bodyBuffer.append("</td></tr>");
                            bodyBuffer.append("</tbody></table>");
                        }
                    }

                    bodyBuffer.append("</td>");

                    break;
                }

                // Add all remaining columns, not including references
                for (int i = 0; i < fields.length; i++) {
                    boolean headerAdded = false;
                    Field field = fields[i];
                    if (field.getName().equals(idColName) || field.getName().equals("links")
                            || field.getName().equals("serialVersionUID")
                            || refNameList.contains(field.getName()))
                        continue;

                    bodyBuffer.append("<td class=\"dataCellText\" nowrap=\"off\">");

                    //System.out.println("metadata "+metadata);
                    //System.out.println("metadata "+fullClassName);
                    //System.out.println(" field.getName() "+ field.getName());
                    if (metadata) {
                        MetadataElement mdata = MetadataCache.getInstance()
                                .getMetadata(caDSRMetadata.CONTEXT_NAME, fullClassName, field.getName());
                        //System.out.println("mdata** "+mdata);
                        //System.out.println("root.getNamespace()** "+root.getNamespace().toString());
                        //System.out.println("child.getNamespace()** "+child.getNamespace().toString());
                        if (mdata != null) {
                            Element attrEle = child.getChild(field.getName(), child.getNamespace());
                            List<Element> children = child.getChildren();

                            if (attrEle != null) {
                                bodyBuffer.append(org.apache.commons.lang.StringEscapeUtils
                                        .escapeHtml(attrEle.getValue()));

                                headerBuffer.append(
                                        "<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                                headerBuffer.append("<a href=\"#\" onclick=\"showMetadata('"
                                        + caDSRMetadata.CONTEXT_NAME + "','" + fullClassName + "','"
                                        + field.getName() + "');return false;\">");
                                headerBuffer.append(field.getName());
                                headerBuffer.append("</a>");
                                headerBuffer.append("</th>");
                                headerAdded = true;
                            }
                        } else {
                            Attribute attr = child.getAttribute(field.getName());
                            if (attr != null) {
                                bodyBuffer.append(
                                        org.apache.commons.lang.StringEscapeUtils.escapeHtml(attr.getValue()));
                            }
                        }
                    } else {
                        Attribute attr = child.getAttribute(field.getName());
                        if (attr != null) {
                            bodyBuffer.append(
                                    org.apache.commons.lang.StringEscapeUtils.escapeHtml(attr.getValue()));
                        }
                    }

                    if (!headerAdded) {
                        headerBuffer.append("<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                        headerBuffer.append(field.getName());
                        headerBuffer.append("</th>");
                    }
                    if (field.getType().getName().startsWith(isoprefix)) {
                        Element childElement = getChild(child, field.getName(), true);
                        if (childElement == null)
                            bodyBuffer.append("&nbsp;");
                        else {
                            bodyBuffer.append(
                                    "<table cellpadding=\"0\" cellspacing=\"2\" width=\"100%\" border=\"0\">");
                            bodyBuffer.append("<tbody><tr class=\"dataRowLight\">");
                            bodyBuffer.append("<td class=\"isoDataCellText\" nowrap=\"off\">");
                            bodyBuffer.append(formatISOElement(childElement));
                            bodyBuffer.append("</td></tr>");
                            bodyBuffer.append("</tbody></table>");

                        }
                    } else {
                        bodyBuffer.append("&nbsp;");
                    }
                    bodyBuffer.append("</td>");
                }

                List<Element> linkChild = getChildren(child, "link");
                for (String linkName : refNameList) {
                    log.debug("linkName: " + linkName);
                    boolean foundLink = false;

                    for (Element link : linkChild) {
                        if (link.getAttribute("ref").getValue().equals(linkName)) {
                            headerBuffer
                                    .append("<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                            headerBuffer.append("&nbsp;");
                            headerBuffer.append("</th>");

                            bodyBuffer.append("<td class=\"dataCellText\" nowrap=\"off\">");
                            bodyBuffer.append("<A href=\"#\" onclick=\"" + "query('"
                                    + link.getAttribute("href").getValue() + "');return false;\"" + ">");
                            bodyBuffer.append(link.getAttribute("ref").getValue());
                            bodyBuffer.append("</A>");
                            bodyBuffer.append("</td>");
                            foundLink = true;
                        }
                    }
                    if (!foundLink) {
                        headerBuffer.append("<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                        headerBuffer.append("&nbsp;");
                        headerBuffer.append("</th>");

                        bodyBuffer.append("<td class=\"dataCellText\" nowrap=\"off\">");
                        bodyBuffer.append("&nbsp;");
                        bodyBuffer.append("</td>");

                    }
                }

                boolean updateLink = supportUpdateLink(classEleName);
                boolean deleteLink = supportDeleteLink(classEleName);

                if (updateLink) {
                    headerBuffer.append("<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                    headerBuffer.append("&nbsp;");
                    headerBuffer.append("</th>");

                    bodyBuffer.append("<td class=\"dataCellText\" nowrap=\"off\">");
                    bodyBuffer.append("<A target=\"_blank\" href=\"Update.action?" + idCol + "=" + idColValue
                            + "&target=" + classEleName + "\">");
                    bodyBuffer.append("Update");
                    bodyBuffer.append("</A>");
                    bodyBuffer.append("</td>");
                }

                if (deleteLink) {
                    headerBuffer.append("<th class=\"dataTableHeader\" scope=\"col\" align=\"center\">");
                    headerBuffer.append("&nbsp;");
                    headerBuffer.append("</th>");

                    bodyBuffer.append("<td class=\"dataCellText\" nowrap=\"off\">");
                    bodyBuffer.append("<A target=\"_blank\" href=\"Delete.action?" + idCol + "=" + idColValue
                            + "&target=" + classEleName + "\">");
                    bodyBuffer.append("Delete");
                    bodyBuffer.append("</A>");
                    bodyBuffer.append("</td>");
                }

                headerBuffer.append("</tr>");
                bodyBuffer.append("</tr>");
                String key = headerBuffer.toString();
                header.put(child.getName(), key);
                List<String> bodyList = body.get(child.getName());
                if (bodyList == null)
                    bodyList = new ArrayList();

                bodyList.add(bodyBuffer.toString());
                body.put(child.getName(), bodyList);
            }

            Iterator headerIter = header.keySet().iterator();
            while (headerIter.hasNext()) {
                String headerName = (String) headerIter.next();
                String headerText = (String) header.get(headerName);
                buffer.append("<tr>");
                buffer.append("<th colspan=\"20\" align=\"left\" scope=\"col\" class=\"dataTableHeader\">");
                buffer.append(classCache.getPkgNameForClass(headerName) + "." + headerName);
                buffer.append("</th>");
                buffer.append("</tr>");

                buffer.append(headerText);
                List<String> bodyList = body.get(headerName);
                for (String bodyRow : bodyList)
                    buffer.append(bodyRow);

                buffer.append("<tr>");
                buffer.append("<th colspan=\"20\" align=\"left\" scope=\"col\" class=\"dataTableHeader\">");
                buffer.append("&nbsp;");
                buffer.append("</th>");
                buffer.append("</tr>");

            }
            buffer.append("</table>");
        }
        buffer.append("</td>");
        buffer.append("</tr>");
        return buffer.toString();

    } catch (Exception ex) {
        ex.printStackTrace();
        log.error(ex.getMessage());
        throw new ServletException(ex.getMessage());
    }
}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.RealWorkflowPortlet.java

/**
 * Workflow exportalas az ETICS rendszerbe (singlenode & multinode tipusu WF)
public void doExportEtics(ActionRequest request, ActionResponse response) throws PortletException {
String msg = new String("");/*from   w  ww  . j  a  v  a  2 s.  c  o  m*/
String retString = "";
try {
    String portalID = new String("http://hostURL:8080/portal30");
    String wfsServiceURL = new String("http://hostURL:8080/wfs");
    String wfsServiceID = new String("/services/urn:wfswfiservice");
    String clientObject = new String("hu.sztaki.lpds.wfs.net.wsaxis13.WfiWfsClientImpl");
    //
        
    WorkflowData wData=PortalCacheService.getInstance().getUser(request.getRemoteUser()).getWorkflow(request.getParameter("workflow"));
    //
        
    Hashtable hsh = new Hashtable();
    hsh.put("url", wData.getWfsID());// PortalCacheService.getInstance().getUser(req.getRemoteUser()).getWorkflow(wfID).getWfsID()
    ServiceType st = InformationBase.getI().getService("wfs", "wfi", hsh, new Vector());
        
        
    WfiWfsClient client = (WfiWfsClient) Class.forName(st.getClientObject()).newInstance();
    client.setServiceURL(st.getServiceUrl());
    client.setServiceID(st.getServiceID());
    //
    ComDataBean comBean = new ComDataBean();
    comBean.setPortalID(PropertyLoader.getInstance().getProperty("service.url"));//portalID
    comBean.setWorkflowtype(wData.getWorkflowType());//"workflowType"
    comBean.setWorkflowID(wData.getWorkflowID());//"workflowID"
    comBean.setGraf(wData.getGraf());//"grafID"
    comBean.setUserID(request.getRemoteUser());//"userID"
    //
    retString = client.getWfiXML(comBean);
    msg=EticsCacheService.getInstance().processWorkflowXml(retString, request.getRemoteUser());
            
    //
} catch (Exception e) {
    e.printStackTrace();
    msg = e.getLocalizedMessage();
}
setRequestAttribute(request.getPortletSession(),"msg",msg);
}
 */

@Override
public void serveResource(ResourceRequest request, ResourceResponse response)
        throws PortletException, IOException {
    String key;
    if ("editgraphURL".equals(request.getResourceID()) && request.getParameter("wfId") != null) {
        GraphEditorUtil.jnpl(request, response);
        return;
    }

    if ("refreshConfigURL".equals(request.getResourceID())) {
        List<String> graphs = new ArrayList<String>();
        Enumeration<String> enm = PortalCacheService.getInstance().getUser(request.getRemoteUser())
                .getAbstactWorkflows().keys();
        while (enm.hasMoreElements())
            graphs.add(enm.nextElement());

        request.setAttribute("graphs", graphs);
        request.setAttribute("workflow", request.getPortletSession().getAttribute("cworkflow"));
        getPortletContext().getRequestDispatcher("/jsp/workflow/accepteditedgraph.jsp").include(request,
                response);
        return;
    }

    // ajax help
    if (request.getParameter("helptext") != null) {
        super.serveResource(request, response);
        return;
    }
    //output download
    if (request.getParameter("downloadType") != null) {
        response.setContentType("application/zip");
        response.setProperty("Content-Disposition", "inline; filename=\"" + request.getParameter("workflowID")
                + "_" + request.getParameter("jobID") + "_" + request.getParameter("pidID") + "_outputs.zip\"");
        try {
            HttpDownload.fileDownload(request.getParameter("downloadType"), request, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PortletException("com error");
        }
        return;
    }
    // logs download  
    if (request.getParameter("fileID") != null) {
        response.setContentType("application/text");
        response.setProperty("Content-Disposition",
                "inline; filename=\"" + request.getParameter("workflowID") + "_" + request.getParameter("jobID")
                        + "_" + request.getParameter("pidID") + "_" + request.getParameter("fileID")
                        + ".txt\"");
        try {
            HttpDownload.fileView(request, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PortletException("com error");
        }
        return;
    }

    // file upload status
    if (request.getParameter("uploadStatus") != null) {
        PortletSession ps = request.getPortletSession();
        // end of download
        if (ps.getAttribute("finaluploads") != null) {
            ps.removeAttribute("finaluploads");
            ps.removeAttribute("uploaded");
            ps.removeAttribute("upload");
            ps.removeAttribute("uploading");
            response.getWriter().write("Upload");

        } else {
            try {
                Vector<String> tmp = (Vector<String>) ps.getAttribute("uploaded");
                response.getWriter().write("&nbsp;<br/>");
                for (String t : tmp)
                    response.getWriter().write("uploaded:" + t + "<br/>");
                FileUploadProgressListener lisener = (FileUploadProgressListener) ((PortletFileUpload) ps
                        .getAttribute("upload")).getProgressListener();
                byte uplStatus = Byte.parseByte(lisener.getFileuploadstatus());
                response.getWriter()
                        .write("uploading:" + ps.getAttribute("uploading") + "->" + "<div style=\"width:"
                                + uplStatus + "px;background-color:blue; \" >" + uplStatus + "%<br/>");
            } catch (Exception ee) {
                System.out.println("file upload has not yet begun " + ps.getId());
                ee.printStackTrace();
            }
        }
        return;
    }
    // configuration
    Hashtable reqhash = new Hashtable();
    Enumeration enm0 = request.getParameterNames();
    while (enm0.hasMoreElements()) {
        key = "" + enm0.nextElement();
        reqhash.put(key, request.getParameter(key));
    }
    reqhash.put("sid", request.getPortletSession().getId());
    try {
        ActionHandler t = null;
        try {
            String sid = request.getPortletSession().getId();
            String workflowName = "" + request.getPortletSession().getAttribute("cworkflow");
            String username = request.getRemoteUser();
            String wftype;
            PortletSession ps = request.getPortletSession();
            if (request.getPortletSession().getAttribute("cworkflow") == null) {
                System.out.println(
                        "RealWFPortlet-serveresource- request.getPortletSession().getAttribute(cworkflow)==null !!!!!!!! try cworkflow1");
                System.out.println("cworkflow1:" + ps.getAttribute("cworkflow1", ps.APPLICATION_SCOPE));
                workflowName = "" + ps.getAttribute("cworkflow1", ps.APPLICATION_SCOPE);
                if (ps.getAttribute("cworkflow1", ps.APPLICATION_SCOPE) != null) {
                    request.getPortletSession().setAttribute("cworkflow", workflowName);
                }
            }
            wftype = PortalCacheService.getInstance().getUser(username).getWorkflow(workflowName)
                    .getWorkflowType();
            reqhash.put("ws-pgrade.wftype", wftype);
            t = (ActionHandler) Class.forName(
                    "hu.sztaki.lpds.pgportal.servlet.ajaxactions." + wftype + "." + request.getParameter("m"))
                    .newInstance();
            //                System.out.println("***SERVE-RESOURCE:"+t.getClass().getName());

        } catch (Exception e) {
            try {
                t = (ActionHandler) Class
                        .forName("hu.sztaki.lpds.pgportal.servlet.ajaxactions." + request.getParameter("m"))
                        .newInstance();
                //                    System.out.println("***SERVE-RESOURCE:"+t.getClass().getName());
            } catch (ClassNotFoundException e0) {
                System.out.println("classnotfound");
                e0.printStackTrace();
            } catch (InstantiationException e0) {
                e0.printStackTrace();
                System.out.println("---Init error:hu.sztaki.lpds.pgportal.servlet.ajaxactions."
                        + request.getParameter("m"));
                e0.printStackTrace();
            } catch (IllegalAccessException e0) {
                e0.printStackTrace();
                System.out.println("---Illegal Access:hu.sztaki.lpds.pgportal.servlet.ajaxactions."
                        + request.getParameter("m"));
                e0.printStackTrace();
            }
        }
        try {
            // Session transfer
            t.setSessionVariables(request.getPortletSession());
            // Parameter setting 
            reqhash.put("user", request.getRemoteUser());
            if (request.getPortletSession().getAttribute("cworkflow") != null)
                reqhash.put("workflow", request.getPortletSession().getAttribute("cworkflow"));
            if (request.getPortletSession().getAttribute("detailsruntime") != null)
                reqhash.put("detailsruntime", request.getPortletSession().getAttribute("detailsruntime"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        // Content transfer
        if (t.getDispacher(reqhash) == null) {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.print(t.getOutput(reqhash));
            } catch (Exception e) {
                e.printStackTrace();
            }
            out.close();
        }
        // Transfer of controlling 
        else {
            Hashtable res = t.getParameters(reqhash);
            Enumeration enm = res.keys();
            while (enm.hasMoreElements()) {
                key = "" + enm.nextElement();
                request.setAttribute(key, res.get(key));
            }
            PortletRequestDispatcher dispatcher = getPortletContext()
                    .getRequestDispatcher(t.getDispacher(reqhash));
            dispatcher.include(request, response);
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("-----------------------Can not be initialized:" + request.getParameter("m"));
    }

}

From source file:Cycloid.Firstex.java

/**
 * Initializes the applet Firstex//from  ww w .j av a2s .co  m
 */
@Override
public void init() {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Firstex.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Firstex.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Firstex.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Firstex.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>

    /* Create and display the applet */
    try {
        java.awt.EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                initComponents();
            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:fr.cobaltians.cobalt.fragments.CobaltFragment.java

private void dismissModal(String controller, String page) {
    try {/*w ww  .jav a  2  s.co m*/
        Class<?> pClass = Class.forName(controller);

        // Instantiates intent only if class inherits from Activity
        if (Activity.class.isAssignableFrom(pClass)) {
            Bundle bundle = new Bundle();
            bundle.putString(Cobalt.kPage, page);

            Intent intent = new Intent(mContext, pClass);
            intent.putExtra(Cobalt.kExtras, bundle);
            intent.putExtra(Cobalt.kPopAsModal, true);

            NavUtils.navigateUpTo((Activity) mContext, intent);
        } else if (Cobalt.DEBUG)
            Log.e(Cobalt.TAG, TAG + " - dismissModal: unable to dismiss modal since " + controller
                    + " does not inherit from Activity");
    } catch (ClassNotFoundException exception) {
        if (Cobalt.DEBUG)
            Log.e(Cobalt.TAG, TAG + " - dismissModal: " + controller + "not found");
        exception.printStackTrace();
    }
}

From source file:Transistor.Transistor.java

@Override
public void init() {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     *///from  ww  w  .j av  a  2  s.com
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Transistor.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Transistor.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Transistor.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Transistor.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>

    /* Create and display the applet */
    try {
        java.awt.EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                initComponents();
            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    info.setPinchOff((int) PinchOffVoltage.getValue());
    info.setVds((int) JFET_VdsSpinner.getValue());
    info.setVgs((int) JFET_VgsSpinner.getValue());
    TestButton.setVisible(false);
}

From source file:AsymptoticFreedom.AppletAF.java

@Override
public void init() {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     *///from www. j  a va  2s .c o  m
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(AppletAF.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(AppletAF.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(AppletAF.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(AppletAF.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>
    //</editor-fold>

    /* Create and display the applet */
    try {
        java.awt.EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                chart = new JFreeChart(new XYPlot());
                initComponents();
            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}