Search in sources :

Example 51 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class ShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.IPreview#preview(org.talend.repository.preview.IProcessDescription,
     * java.lang.String, boolean)
     */
public CsvArray preview(IProcessDescription description, String type, boolean outputErrorAsException) throws CoreException {
    CsvArray res = null;
    EShadowProcessType typeShadow = EShadowProcessType.valueOf(type);
    shadowProcess = new ShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.runWithErrorOutputAsException(outputErrorAsException);
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription) EShadowProcessType(org.talend.designer.runprocess.shadow.ShadowProcess.EShadowProcessType)

Example 52 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class JavaProcessor method getLineNumbers.

/**
     * Find line numbers of the beginning of the code of process nodes.
     *
     * @param file Code file where we are searching node's code.
     * @param nodes List of nodes searched.
     * @return Line numbers where code of nodes appears.
     * @throws CoreException Search failed.
     */
private static int[] getLineNumbers(IFile file, String[] nodes) throws CoreException {
    List<Integer> lineNumbers = new ArrayList<Integer>();
    // List of code's lines searched in the file
    List<String> searchedLines = new ArrayList<String>();
    for (String node : nodes) {
        searchedLines.add(node);
    }
    LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(file.getContents()));
    try {
        String line = lineReader.readLine();
        while (!searchedLines.isEmpty() && line != null) {
            boolean nodeFound = false;
            for (Iterator<String> i = searchedLines.iterator(); !nodeFound && i.hasNext(); ) {
                String nodeMain = i.next();
                if (line.indexOf(nodeMain) != -1) {
                    nodeFound = true;
                    i.remove();
                    // Search the first valid code line
                    boolean lineCodeFound = false;
                    line = lineReader.readLine();
                    while (line != null && !lineCodeFound) {
                        if (isCodeLine(line)) {
                            lineCodeFound = true;
                            lineNumbers.add(new Integer(lineReader.getLineNumber() + 1));
                        }
                        line = lineReader.readLine();
                    }
                }
            }
            line = lineReader.readLine();
        }
    } catch (IOException ioe) {
        //$NON-NLS-1$ //$NON-NLS-2$
        IStatus status = new Status(IStatus.ERROR, "", IStatus.OK, "Source code read failure.", ioe);
        throw new CoreException(status);
    }
    int[] res = new int[lineNumbers.size()];
    int pos = 0;
    for (Integer i : lineNumbers) {
        res[pos++] = i.intValue();
    }
    return res;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) InputStreamReader(java.io.InputStreamReader) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) LineNumberReader(java.io.LineNumberReader) CoreException(org.eclipse.core.runtime.CoreException)

Example 53 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class JavaProcessor method copyEsbConfigFile.

private static void copyEsbConfigFile(File esbConfigsSourceFolder, IFolder esbConfigsTargetFolder, String configFile) {
    File esbConfig = new File(esbConfigsSourceFolder, configFile);
    if (esbConfig.exists()) {
        try {
            IFile target = esbConfigsTargetFolder.getFile(configFile);
            InputStream is = null;
            try {
                is = new FileInputStream(esbConfig);
                if (!target.exists()) {
                    target.create(is, true, null);
                } else {
                    target.setContents(is, true, false, null);
                }
            } finally {
                if (null != is) {
                    is.close();
                }
            }
        // esbConfig.copy(esbConfigsTargetFolder.getChild(configFile), EFS.OVERWRITE, null);
        } catch (Exception e) {
            RunProcessPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, RunProcessPlugin.getDefault().getBundle().getSymbolicName(), //$NON-NLS-1$
            "cannot add configuration file on classpath - " + configFile, e));
        }
    } else {
        RunProcessPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, RunProcessPlugin.getDefault().getBundle().getSymbolicName(), //$NON-NLS-1$
        "cannot find configuration file - " + esbConfig.toURI()));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Base64InputStream(org.apache.commons.codec.binary.Base64InputStream) ZipInputStream(java.util.zip.ZipInputStream) InflaterInputStream(java.util.zip.InflaterInputStream) FilterInputStream(java.io.FilterInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IFile(org.eclipse.core.resources.IFile) File(java.io.File) FileInputStream(java.io.FileInputStream) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) IOException(java.io.IOException) SystemException(org.talend.commons.exception.SystemException) ProcessorException(org.talend.designer.runprocess.ProcessorException)

Example 54 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class JSONShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.IPreview#preview(org.talend.repository.preview.IProcessDescription,
     * java.lang.String, boolean)
     */
public CsvArray preview(IProcessDescription description, String type, boolean outputErrorAsException) throws CoreException {
    CsvArray res = null;
    EJSONShadowProcessType typeShadow = EJSONShadowProcessType.valueOf(type);
    shadowProcess = new JSONShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.runWithErrorOutputAsException(outputErrorAsException);
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : EJSONShadowProcessType(org.talend.repository.json.ui.shadow.JSONShadowProcess.EJSONShadowProcessType) Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription)

Example 55 with Status

use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.

the class JSONShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.filedelimited.IFileDelimitedPreview#
     * preview(org.talend.repository.preview.filedelimited.ProcessDescription)
     */
public CsvArray preview(IProcessDescription description, String type) throws CoreException {
    CsvArray res = null;
    EJSONShadowProcessType typeShadow = EJSONShadowProcessType.valueOf(type);
    shadowProcess = new JSONShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.run();
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : EJSONShadowProcessType(org.talend.repository.json.ui.shadow.JSONShadowProcess.EJSONShadowProcessType) Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription)

Aggregations

Status (org.eclipse.core.runtime.Status)538 IStatus (org.eclipse.core.runtime.IStatus)513 CoreException (org.eclipse.core.runtime.CoreException)248 IOException (java.io.IOException)110 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)84 ArrayList (java.util.ArrayList)62 InvocationTargetException (java.lang.reflect.InvocationTargetException)60 IFile (org.eclipse.core.resources.IFile)54 File (java.io.File)53 MultiStatus (org.eclipse.core.runtime.MultiStatus)43 IResource (org.eclipse.core.resources.IResource)41 IPath (org.eclipse.core.runtime.IPath)41 InputStream (java.io.InputStream)36 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)34 PartInitException (org.eclipse.ui.PartInitException)32 IProject (org.eclipse.core.resources.IProject)31 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)25 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)24 SubMonitor (org.eclipse.core.runtime.SubMonitor)24 ITask (com.cubrid.common.core.task.ITask)23