Search in sources :

Example 1 with Status

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

the class ImportOperation method importFileSystemObjects.

/**
     * Imports the specified file system objects into the workspace.
     * If the import fails, adds a status object to the list to be returned by
     * <code>getStatus</code>.
     *
     * @param filesToImport the list of file system objects to import
     *   (element type: <code>Object</code>)
     * @throws CoreException
     * @exception OperationCanceledException if canceled
     */
void importFileSystemObjects(List filesToImport) throws CoreException {
    Iterator filesEnum = filesToImport.iterator();
    while (filesEnum.hasNext()) {
        Object fileSystemObject = filesEnum.next();
        if (source == null) {
            // We just import what we are given into the destination
            IPath sourcePath = new Path(provider.getFullPath(fileSystemObject)).removeLastSegments(1);
            if (provider.isFolder(fileSystemObject) && sourcePath.isEmpty()) {
                // If we don't have a parent then we have selected the
                // file systems root. Roots can't copied (at least not
                // under windows).
                errorTable.add(new Status(IStatus.INFO, PlatformUI.PLUGIN_ID, 0, "DataTransferMessages.ImportOperation_cannotCopy", null));
                continue;
            }
            source = sourcePath.toFile();
        }
        importRecursivelyFrom(fileSystemObject, POLICY_DEFAULT);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IPath(org.eclipse.core.runtime.IPath) Iterator(java.util.Iterator)

Example 2 with Status

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

the class JavaSearchResult method addMatch.

boolean addMatch(Match match, IMatchPresentation participant) {
    Object element = match.getElement();
    if (fElementsToParticipants.get(element) != null) {
        // TODO must access the participant id / label to properly report the error.
        JavaPlugin.log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), 0, "A second search participant was found for an element", //$NON-NLS-1$
        null));
        return false;
    }
    fElementsToParticipants.put(element, participant);
    addMatch(match);
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status)

Example 3 with Status

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

the class RefactoringSessionReader method readSession.

/**
	 * Reads a refactoring history descriptor from the specified input object.
	 *
	 * @param source
	 *            the input source
	 * @return a corresponding refactoring history descriptor, or
	 *         <code>null</code>
	 * @throws CoreException
	 *             if an error occurs while reading form the input source
	 */
public RefactoringSessionDescriptor readSession(final InputSource source) throws CoreException {
    fSessionFound = false;
    try {
        //$NON-NLS-1$
        source.setSystemId("/");
        createParser(SAXParserFactory.newInstance()).parse(source, this);
        if (!fSessionFound)
            throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, RefactoringCoreMessages.RefactoringSessionReader_no_session, null));
        if (fRefactoringDescriptors != null) {
            if (//$NON-NLS-1$
            fVersion == null || "".equals(fVersion))
                throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.MISSING_REFACTORING_HISTORY_VERSION, RefactoringCoreMessages.RefactoringSessionReader_missing_version_information, null));
            if (!IRefactoringSerializationConstants.CURRENT_VERSION.equals(fVersion))
                throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.UNSUPPORTED_REFACTORING_HISTORY_VERSION, RefactoringCoreMessages.RefactoringSessionReader_unsupported_version_information, null));
            return new RefactoringSessionDescriptor((RefactoringDescriptor[]) fRefactoringDescriptors.toArray(new RefactoringDescriptor[fRefactoringDescriptors.size()]), fVersion, fComment);
        }
    } catch (IOException exception) {
        throwCoreException(exception, exception.getLocalizedMessage());
    } catch (ParserConfigurationException exception) {
        throwCoreException(exception, exception.getLocalizedMessage());
    } catch (SAXParseException exception) {
        String message = Messages.format(RefactoringCoreMessages.RefactoringSessionReader_invalid_contents_at, new Object[] { Integer.toString(exception.getLineNumber()), Integer.toString(exception.getColumnNumber()) });
        throwCoreException(exception, message);
    } catch (SAXException exception) {
        throwCoreException(exception, exception.getLocalizedMessage());
    } finally {
        fRefactoringDescriptors = null;
        fVersion = null;
        fComment = null;
        fLocator = null;
    }
    return null;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) DefaultRefactoringDescriptor(org.eclipse.ltk.internal.core.refactoring.history.DefaultRefactoringDescriptor) RefactoringDescriptor(org.eclipse.ltk.core.refactoring.RefactoringDescriptor) CoreException(org.eclipse.core.runtime.CoreException) SAXParseException(org.xml.sax.SAXParseException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) RefactoringSessionDescriptor(org.eclipse.ltk.core.refactoring.RefactoringSessionDescriptor) SAXException(org.xml.sax.SAXException)

Example 4 with Status

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

the class RefactoringSessionTransformer method createArgument.

/**
	 * Creates a refactoring argument with the specified name and value.
	 * <p>
	 * If no refactoring is currently processed, this call has no effect.
	 * </p>
	 *
	 * @param name
	 *            the non-empty name of the argument
	 * @param value
	 *            the value of the argument
	 *
	 * @throws CoreException
	 *             if an error occurs while creating a new argument
	 */
public void createArgument(final String name, final String value) throws CoreException {
    Assert.isNotNull(name);
    //$NON-NLS-1$
    Assert.isTrue(!"".equals(name));
    Assert.isNotNull(value);
    if (fDocument != null && fRefactoringArguments != null && value != null) {
        try {
            final Attr attribute = fDocument.createAttribute(name);
            attribute.setValue(value);
            fRefactoringArguments.add(attribute);
        } catch (DOMException exception) {
            throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, exception.getLocalizedMessage(), null));
        }
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) DOMException(org.w3c.dom.DOMException) CoreException(org.eclipse.core.runtime.CoreException) Attr(org.w3c.dom.Attr)

Example 5 with Status

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

the class RefactoringHistoryManager method checkArgumentMap.

/**
	 * Checks whether the argument map is well-formed.
	 * <p>
	 * All arguments contained in the map are checked according to the rules of
	 * {@link RefactoringDescriptor}.
	 * </p>
	 *
	 * @param arguments
	 *            the argument map
	 * @throws CoreException
	 *             if the argument violates any of the constraints
	 */
public static void checkArgumentMap(final Map arguments) throws CoreException {
    Assert.isNotNull(arguments);
    for (final Iterator iterator = arguments.entrySet().iterator(); iterator.hasNext(); ) {
        final Map.Entry entry = (Map.Entry) iterator.next();
        if (entry.getKey() instanceof String) {
            final String string = (String) entry.getKey();
            final char[] characters = string.toCharArray();
            if (characters.length == 0) {
                throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, RefactoringCoreMessages.RefactoringHistoryManager_empty_argument, null));
            }
            for (int index = 0; index < characters.length; index++) {
                if (Character.isWhitespace(characters[index]))
                    throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, RefactoringCoreMessages.RefactoringHistoryManager_whitespace_argument_key, null));
            }
        } else {
            throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, Messages.format(RefactoringCoreMessages.RefactoringHistoryManager_non_string_argument, entry.getKey()), null));
        }
        if (!(entry.getValue() instanceof String)) {
            throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, Messages.format(RefactoringCoreMessages.RefactoringHistoryManager_non_string_value, entry.getKey()), null));
        }
    }
}
Also used : Entry(java.util.Map.Entry) MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Entry(java.util.Map.Entry) CoreException(org.eclipse.core.runtime.CoreException) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) NamedNodeMap(org.w3c.dom.NamedNodeMap)

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