use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.
the class XtextDocumentProvider method loadResource.
protected void loadResource(XtextResource resource, String document, String encoding) throws CoreException {
try {
byte[] bytes = encoding != null ? document.getBytes(encoding) : document.getBytes();
resource.load(new ByteArrayInputStream(bytes), Collections.singletonMap(XtextResource.OPTION_ENCODING, encoding));
} catch (IOException ex) {
String message = (ex.getMessage() != null ? ex.getMessage() : ex.toString());
IStatus s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, ex);
throw new CoreException(s);
}
}
use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.
the class XbaseDocumentProvider method createElementInfo.
@Override
protected ElementInfo createElementInfo(Object element) throws CoreException {
if (element instanceof IClassFileEditorInput) {
IDocument document = null;
IStatus status = null;
try {
document = createDocument(element);
} catch (CoreException x) {
status = x.getStatus();
document = createEmptyDocument();
}
ClassFileInfo info = new ClassFileInfo(document, createAnnotationModel(element));
info.fStatus = status;
registerAnnotationInfoProcessor(info);
return info;
}
return super.createElementInfo(element);
}
use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.
the class WizardNewXtextProjectCreationPage method validatePage.
@Override
protected boolean validatePage() {
if (!super.validatePage())
return false;
IStatus status = validateProjectName();
if (!status.isOK()) {
setErrorMessage(status.getMessage());
return false;
}
if (// See the comment in createControl
languageNameField == null)
return true;
if (languageNameField.getText().length() == 0)
return false;
status = JavaConventions.validateJavaTypeName(languageNameField.getText(), JavaCore.VERSION_1_5, JavaCore.VERSION_1_5);
if (!status.isOK()) {
setErrorMessage(Messages.WizardNewXtextProjectCreationPage_ErrorMessageLanguageName + status.getMessage());
return false;
}
if (!languageNameField.getText().contains(".")) {
// $NON-NLS-1$
setErrorMessage(Messages.WizardNewXtextProjectCreationPage_ErrorMessageLanguageNameWithoutPackage);
return false;
}
if (extensionsField.getText().length() == 0)
return false;
if (!PATTERN_EXTENSIONS.matcher(extensionsField.getText()).matches()) {
setErrorMessage(Messages.WizardNewXtextProjectCreationPage_ErrorMessageExtensions);
return false;
}
if (!Sets.newHashSet(JREContainerProvider.getConfiguredBREEs()).contains(breeCombo.getText())) {
setMessage(Messages.WizardNewXtextProjectCreationPage_eeInfo_0 + breeCombo.getText() + Messages.WizardNewXtextProjectCreationPage_eeInfo_1, IMessageProvider.INFORMATION);
return true;
}
setErrorMessage(null);
setMessage(null);
return true;
}
use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.
the class OptionsConfigurationBlock method logError.
private void logError(String text, IOException e) {
IStatus status = new Status(IStatus.ERROR, uiPlugin.getBundle().getSymbolicName(), text, e);
uiPlugin.getLog().log(status);
}
use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.
the class ProjectOpenedOrClosedListener method scheduleRemoveProjectJob.
protected void scheduleRemoveProjectJob(final IProject project) {
final ToBeBuilt toBeBuilt = getToBeBuiltComputer().removeProject(project, new NullProgressMonitor());
if (toBeBuilt.getToBeDeleted().isEmpty() && toBeBuilt.getToBeUpdated().isEmpty())
return;
new Job(Messages.ProjectOpenedOrClosedListener_RemovingProject + project.getName() + Messages.ProjectOpenedOrClosedListener_FromIndex) {
{
setRule(workspace.getRoot());
}
@Override
public boolean belongsTo(Object family) {
return family == ResourcesPlugin.FAMILY_AUTO_BUILD;
}
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
new WorkspaceModifyOperation(getRule()) {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
SubMonitor progress = SubMonitor.convert(monitor, 1);
try {
ResourceSet resourceSet = getResourceSetProvider().get(project);
resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
if (resourceSet instanceof ResourceSetImpl) {
((ResourceSetImpl) resourceSet).setURIResourceMap(Maps.<URI, Resource>newHashMap());
}
BuildData buildData = new BuildData(project.getName(), resourceSet, toBeBuilt, queuedBuildData);
getBuilderState().update(buildData, progress.newChild(1));
resourceSet.getResources().clear();
resourceSet.eAdapters().clear();
} catch (OperationCanceledException e) {
throw new InterruptedException();
} finally {
if (monitor != null)
monitor.done();
}
}
}.run(monitor);
} catch (InvocationTargetException e) {
log.error(e.getMessage(), e);
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
}.schedule();
}
Aggregations