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);
}
}
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;
}
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;
}
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));
}
}
}
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));
}
}
}
Aggregations