use of org.eclipse.core.runtime.MultiStatus in project che by eclipse.
the class Workspace method delete.
@Override
public IStatus delete(IResource[] resources, int updateFlags, IProgressMonitor monitor) throws CoreException {
monitor = Policy.monitorFor(monitor);
try {
int opWork = Math.max(resources.length, 1);
int totalWork = Policy.totalWork * opWork / Policy.opWork;
String message = Messages.resources_deleting_0;
monitor.beginTask(message, totalWork);
message = Messages.resources_deleteProblem;
MultiStatus result = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.INTERNAL_ERROR, message, null);
if (resources.length == 0)
return result;
// to avoid concurrent changes to this array
resources = resources.clone();
try {
prepareOperation(getRoot(), monitor);
beginOperation(true);
for (int i = 0; i < resources.length; i++) {
Policy.checkCanceled(monitor);
Resource resource = (Resource) resources[i];
if (resource == null) {
monitor.worked(1);
continue;
}
try {
resource.delete(updateFlags, Policy.subMonitorFor(monitor, 1));
} catch (CoreException e) {
// Don't really care about the exception unless the resource is still around.
ResourceInfo info = resource.getResourceInfo(false, false);
if (resource.exists(resource.getFlags(info), false)) {
message = NLS.bind(Messages.resources_couldnotDelete, resource.getFullPath());
result.merge(new org.eclipse.core.internal.resources.ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, resource.getFullPath(), message));
result.merge(e.getStatus());
}
}
}
if (result.matches(IStatus.ERROR))
throw new ResourceException(result);
return result;
} catch (OperationCanceledException e) {
getWorkManager().operationCanceled();
throw e;
} finally {
endOperation(getRoot(), true, Policy.subMonitorFor(monitor, totalWork - opWork));
}
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.MultiStatus in project che by eclipse.
the class RefactoringHistoryManager method getCachedSession.
/**
* Returns the cached refactoring session descriptor.
*
* @param store
* the file store of the descriptor
* @param projectName
* project name, or <code>null</code> for the workspace
* @param input
* the input stream where to read the descriptor
* @return the cached refactoring session descriptor
* @throws CoreException
* if an error occurs while reading the session
*/
private RefactoringSessionDescriptor getCachedSession(final IFileStore store, String projectName, final InputStream input) throws CoreException {
if (store.equals(fCachedStore) && fCachedDescriptor != null)
return fCachedDescriptor;
final RefactoringSessionDescriptor descriptor;
try {
descriptor = new RefactoringSessionReader(false, projectName).readSession(new InputSource(input));
fCachedDescriptor = descriptor;
fCachedStore = store;
return descriptor;
} catch (CoreException e) {
throw new CoreException(new MultiStatus(RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_IO_ERROR, new IStatus[] { e.getStatus() }, Messages.format(RefactoringCoreMessages.RefactoringHistoryManager_error_reading_file, BasicElementLabels.getURLPart(store.toURI().toString())), null));
}
}
use of org.eclipse.core.runtime.MultiStatus in project cubrid-manager by CUBRID.
the class ImportDataFromFileDialog method finish.
/**
*
* After task finished, call it
*
*
*
*/
private void finish() {
if (getStartShowResult()) {
return;
} else {
setStartShowResult(true);
}
if (importFileHandler instanceof XLSImportFileHandler) {
XLSImportFileHandler xlsHandler = (XLSImportFileHandler) importFileHandler;
xlsHandler.dispose();
} else if (importFileHandler instanceof XLSXImportFileHandler) {
XLSXImportFileHandler xlsHandler = (XLSXImportFileHandler) importFileHandler;
xlsHandler.dispose();
}
long endTimestamp = System.currentTimeMillis();
String spendTime = calcSpendTime(beginTimestamp, endTimestamp);
List<Status> allStatusList = new ArrayList<Status>();
int commitedCount = 0;
boolean isHasError = false;
boolean isCancel = false;
List<String> errorList = new ArrayList<String>();
int totalErrorCount = 0;
for (PstmtDataTask task : taskList) {
commitedCount += task.getCommitedCount();
isCancel = isCancel || task.isCancel();
if (!task.isSuccess() && task.getErrorMsg() != null) {
Status status = new Status(IStatus.ERROR, CommonUIPlugin.PLUGIN_ID, task.getErrorMsg());
allStatusList.add(status);
isHasError = true;
}
errorList.addAll(task.getErrorMsgList());
totalErrorCount = totalErrorCount + task.getTotalErrorCount();
if (!errorList.isEmpty()) {
isHasError = true;
}
}
if (!isHasError && isCancel) {
String msg = Messages.bind(Messages.msgCancelExecSql, new String[] { String.valueOf(commitedCount), spendTime });
CommonUITool.openInformationBox(getShell(), Messages.titleExecuteResult, msg);
close();
deleteLog();
return;
}
String successMsg = Messages.bind(Messages.msgSuccessExecSql, new String[] { String.valueOf(commitedCount), spendTime });
if (!isHasError) {
CommonUITool.openInformationBox(getShell(), Messages.titleExecuteResult, successMsg);
close();
deleteLog();
return;
}
if (errorList.isEmpty()) {
// break
Status status = new Status(IStatus.INFO, CommonUIPlugin.PLUGIN_ID, successMsg + "\r\n");
allStatusList.add(0, status);
IStatus[] errors = new IStatus[allStatusList.size()];
allStatusList.toArray(errors);
MultiStatus multiStatus = new MultiStatus(CommonUIPlugin.PLUGIN_ID, IStatus.OK, errors, Messages.msgDetailCause, null);
String errorMsg = Messages.bind(Messages.errExecSql, new String[] { String.valueOf(commitedCount), spendTime });
ErrorDialog errorDialog = new ErrorDialog(getShell(), Messages.titleExecuteResult, errorMsg, multiStatus, IStatus.INFO | IStatus.ERROR);
errorDialog.open();
if (isHasError) {
getShell().setVisible(true);
} else {
close();
}
} else {
//ignore the error
String msg = Messages.bind(Messages.importColumnNOTotal, String.valueOf(totalErrorCount)) + "\r\n" + successMsg;
ImportResultDialog dialog = new ImportResultDialog(getShell(), msg, errorList, errorLogDir);
dialog.open();
close();
}
deleteLog();
}
use of org.eclipse.core.runtime.MultiStatus in project translationstudio8 by heartsome.
the class OpenMessageUtils method throwable2MultiStatus.
/**
* 将<code>Throwable<code>转化成<code>MultiStatus<code>对象,
* 让<code>MultiStatus<code>对象包含详细的<code>Throwable<code>详细的堆栈信息。
* @param message
* <code>MultiStatus<code>对象的消息
* @param throwable
* 异常对象
* @return 包含有详细的堆栈信息的<code>MultiStatus<code>对象;
*/
public static MultiStatus throwable2MultiStatus(String message, Throwable throwable) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
throwable.printStackTrace(pw);
// stack trace as a string
final String trace = sw.toString();
// Temp holder of child statuses
List<Status> childStatuses = new ArrayList<Status>();
// Split output by OS-independend new-line
//$NON-NLS-N$
String[] lines = trace.split(System.getProperty("line.separator"));
int j = lines.length == 1 ? 0 : 1;
for (int i = j; i < lines.length; i++) {
String line = lines[i];
// build & add status
childStatuses.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, line));
}
// convert to array of statuses
MultiStatus ms = new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR, childStatuses.toArray(new Status[] {}), message, throwable);
return ms;
}
use of org.eclipse.core.runtime.MultiStatus in project translationstudio8 by heartsome.
the class ResourceDropAdapterAssistant method performResourceCopy.
/**
* Performs a resource copy
*/
private IStatus performResourceCopy(CommonDropAdapter dropAdapter, Shell shell, IResource[] sources) {
MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1, WorkbenchNavigatorMessages.resources_ResourceDropAdapterAssistant_problemsMoving, null);
mergeStatus(problems, validateTarget(dropAdapter.getCurrentTarget(), dropAdapter.getCurrentTransfer(), dropAdapter.getCurrentOperation()));
IContainer target = getActualTarget((IResource) dropAdapter.getCurrentTarget());
boolean shouldLinkAutomatically = false;
if (target.isVirtual()) {
shouldLinkAutomatically = true;
for (int i = 0; i < sources.length; i++) {
if ((sources[i].getType() != IResource.FILE) && (sources[i].getLocation() != null)) {
// If the source is a folder, but the location is null (a
// broken link, for example),
// we still generate a link automatically (the best option).
shouldLinkAutomatically = false;
break;
}
}
}
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
// automatically create links
if (shouldLinkAutomatically) {
operation.setCreateLinks(true);
operation.copyResources(sources, target);
} else {
// boolean allSourceAreLinksOrVirtualFolders = true;
// for (int i = 0; i < sources.length; i++) {
// if (!sources[i].isVirtual() && !sources[i].isLinked()) {
// allSourceAreLinksOrVirtualFolders = false;
// break;
// }
// }
// // if all sources are either links or groups, copy then normally,
// // don't show the dialog
// if (!allSourceAreLinksOrVirtualFolders) {
// IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
// String dndPreference= store.getString(target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE : IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);
//
// if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) {
// ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
// dialog.setResource(target);
// if (dialog.open() == Window.OK) {
// if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
// operation.setVirtualFolders(true);
// if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
// operation.setCreateLinks(true);
// if (dialog.getVariable() != null)
// operation.setRelativeVariable(dialog.getVariable());
// operation.copyResources(sources, target);
// } else
// return problems;
// }
// else
// operation.copyResources(sources, target);
// } else
operation.copyResources(sources, target);
}
return problems;
}
Aggregations