Search in sources :

Example 11 with Status

use of org.eclipse.core.runtime.Status in project che by eclipse.

the class JavaConventions method validateClassFileName.

/**
     * Validate the given .class file name for the given source and compliance levels.
     * <p>
     * A .class file name must obey the following rules:
     * <ul>
     * <li> it must not be null
     * <li> it must include the <code>".class"</code> suffix
     * <li> its prefix must be a valid identifier
     * <li> it must not contain any characters or substrings that are not valid
     *		   on the file system on which workspace root is located.
     * </ul>
     * </p>
     * @param name the name of a .class file
     * @param sourceLevel the source level
     * @param complianceLevel the compliance level
     * @return a status object with code <code>IStatus.OK</code> if
     *		the given name is valid as a .class file name, otherwise a status
     *		object indicating what is wrong with the name
     * @since 3.3
     */
public static IStatus validateClassFileName(String name, String sourceLevel, String complianceLevel) {
    if (name == null) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_nullName, null);
    }
    if (!org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(name)) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName, null);
    }
    String identifier;
    int index;
    index = name.lastIndexOf('.');
    if (index == -1) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName, null);
    }
    identifier = name.substring(0, index);
    // the package-level spec (replaces package.html)
    if (!identifier.equals(PACKAGE_INFO)) {
        IStatus status = validateIdentifier(identifier, sourceLevel, complianceLevel);
        if (!status.isOK()) {
            return status;
        }
    }
    //        }
    return JavaModelStatus.VERIFIED_OK;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) JavaModelStatus(org.eclipse.jdt.internal.core.JavaModelStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus)

Example 12 with Status

use of org.eclipse.core.runtime.Status in project che by eclipse.

the class DeltaProcessingState method saveExternalLibTimeStamps.

public void saveExternalLibTimeStamps() throws CoreException {
    if (this.externalTimeStamps == null)
        return;
    // cleanup to avoid any leak ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=244849 )
    HashSet toRemove = new HashSet();
    if (this.roots != null) {
        Enumeration keys = this.externalTimeStamps.keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            if (this.roots.get(key) == null) {
                toRemove.add(key);
            }
        }
    }
    File timestamps = getTimeStampsFile();
    DataOutputStream out = null;
    try {
        out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(timestamps)));
        out.writeInt(this.externalTimeStamps.size() - toRemove.size());
        Iterator entries = this.externalTimeStamps.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            IPath key = (IPath) entry.getKey();
            if (!toRemove.contains(key)) {
                out.writeUTF(key.toPortableString());
                Long timestamp = (Long) entry.getValue();
                out.writeLong(timestamp.longValue());
            }
        }
    } catch (IOException e) {
        //$NON-NLS-1$
        IStatus status = new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, IStatus.ERROR, "Problems while saving timestamps", e);
        throw new CoreException(status);
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
            // nothing we can do: ignore
            }
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) Enumeration(java.util.Enumeration) IPath(org.eclipse.core.runtime.IPath) DataOutputStream(java.io.DataOutputStream) IOException(java.io.IOException) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) CoreException(org.eclipse.core.runtime.CoreException) FileOutputStream(java.io.FileOutputStream) Iterator(java.util.Iterator) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 13 with Status

use of org.eclipse.core.runtime.Status in project che by eclipse.

the class JavadocContentAccess2 method getContentsFromInputStream.

private static String getContentsFromInputStream(InputStream in, String encoding) throws CoreException {
    final int defaultFileSize = 15 * 1024;
    StringBuffer buffer = new StringBuffer(defaultFileSize);
    Reader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(in, encoding), defaultFileSize);
        char[] readBuffer = new char[2048];
        int charCount = reader.read(readBuffer);
        while (charCount > 0) {
            buffer.append(readBuffer, 0, charCount);
            charCount = reader.read(readBuffer);
        }
    } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, "JavaPlugin.getPluginId()", e.getMessage(), e));
    } finally {
        try {
            if (reader != null) {
                //this will also close the InputStream wrapped in the reader
                reader.close();
            }
        } catch (IOException e) {
        //ignore
        }
    }
    return buffer.toString();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InputStreamReader(java.io.InputStreamReader) CoreException(org.eclipse.core.runtime.CoreException) BufferedReader(java.io.BufferedReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 14 with Status

use of org.eclipse.core.runtime.Status in project che by eclipse.

the class JavaConventions method validateCompilationUnitName.

/**
	 * Validate the given compilation unit name for the given source and compliance levels.
	 * <p>
	 * A compilation unit name must obey the following rules:
	 * <ul>
	 * <li> it must not be null
	 * <li> it must be suffixed by a dot ('.') followed by one of the
	 *       {@link org.eclipse.jdt.core.JavaCore#getJavaLikeExtensions() Java-like extensions}
	 * <li> its prefix must be a valid identifier
	 * <li> it must not contain any characters or substrings that are not valid
	 *		   on the file system on which workspace root is located.
	 * </ul>
	 * </p>
	 * @param name the name of a compilation unit
	 * @param sourceLevel the source level
	 * @param complianceLevel the compliance level
	 * @return a status object with code <code>IStatus.OK</code> if
	 *		the given name is valid as a compilation unit name, otherwise a status
	 *		object indicating what is wrong with the name
	 * @since 3.3
	 */
public static IStatus validateCompilationUnitName(String name, String sourceLevel, String complianceLevel) {
    if (name == null) {
        return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1, Messages.convention_unit_nullName, null);
    }
    if (!org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(name)) {
        return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1, Messages.convention_unit_notJavaName, null);
    }
    String identifier;
    int index;
    index = name.lastIndexOf('.');
    if (index == -1) {
        return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1, Messages.convention_unit_notJavaName, null);
    }
    identifier = name.substring(0, index);
    // the package-level spec (replaces package.html)
    if (!identifier.equals(PACKAGE_INFO)) {
        IStatus status = validateIdentifier(identifier, sourceLevel, complianceLevel);
        if (!status.isOK()) {
            return status;
        }
    }
    //		}
    return JavaModelStatus.VERIFIED_OK;
}
Also used : JavaModelStatus(org.eclipse.jdt.internal.core.JavaModelStatus) Status(org.eclipse.core.runtime.Status) IJavaModelStatus(org.eclipse.jdt.core.IJavaModelStatus) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus)

Example 15 with Status

use of org.eclipse.core.runtime.Status in project che by eclipse.

the class JavaConventions method validateClassFileName.

/**
	 * Validate the given .class file name for the given source and compliance levels.
	 * <p>
	 * A .class file name must obey the following rules:
	 * <ul>
	 * <li> it must not be null
	 * <li> it must include the <code>".class"</code> suffix
	 * <li> its prefix must be a valid identifier
	 * <li> it must not contain any characters or substrings that are not valid
	 *		   on the file system on which workspace root is located.
	 * </ul>
	 * </p>
	 * @param name the name of a .class file
	 * @param sourceLevel the source level
	 * @param complianceLevel the compliance level
	 * @return a status object with code <code>IStatus.OK</code> if
	 *		the given name is valid as a .class file name, otherwise a status
	 *		object indicating what is wrong with the name
	 * @since 3.3
	 */
public static IStatus validateClassFileName(String name, String sourceLevel, String complianceLevel) {
    if (name == null) {
        return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_nullName, null);
    }
    if (!org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(name)) {
        return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName, null);
    }
    String identifier;
    int index;
    index = name.lastIndexOf('.');
    if (index == -1) {
        return new Status(IStatus.ERROR, org.eclipse.jdt.core.JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName, null);
    }
    identifier = name.substring(0, index);
    // the package-level spec (replaces package.html)
    if (!identifier.equals(PACKAGE_INFO)) {
        IStatus status = validateIdentifier(identifier, sourceLevel, complianceLevel);
        if (!status.isOK()) {
            return status;
        }
    }
    //		}
    return JavaModelStatus.VERIFIED_OK;
}
Also used : JavaModelStatus(org.eclipse.jdt.internal.core.JavaModelStatus) Status(org.eclipse.core.runtime.Status) IJavaModelStatus(org.eclipse.jdt.core.IJavaModelStatus) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus)

Aggregations

Status (org.eclipse.core.runtime.Status)305 IStatus (org.eclipse.core.runtime.IStatus)282 CoreException (org.eclipse.core.runtime.CoreException)132 IOException (java.io.IOException)66 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)64 InvocationTargetException (java.lang.reflect.InvocationTargetException)40 File (java.io.File)38 ArrayList (java.util.ArrayList)37 IFile (org.eclipse.core.resources.IFile)37 MultiStatus (org.eclipse.core.runtime.MultiStatus)30 IResource (org.eclipse.core.resources.IResource)27 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)26 IProject (org.eclipse.core.resources.IProject)24 IPath (org.eclipse.core.runtime.IPath)24 ITask (com.cubrid.common.core.task.ITask)23 PartInitException (org.eclipse.ui.PartInitException)23 InputStream (java.io.InputStream)18 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 Composite (org.eclipse.swt.widgets.Composite)16