Search in sources :

Example 81 with IStatus

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);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException)

Example 82 with IStatus

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);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) WrappedCoreException(org.eclipse.xtext.ui.generator.trace.WrappedCoreException) IClassFileEditorInput(org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Example 83 with IStatus

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus)

Example 84 with IStatus

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);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus)

Example 85 with IStatus

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();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)1423 Status (org.eclipse.core.runtime.Status)500 CoreException (org.eclipse.core.runtime.CoreException)369 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)270 File (java.io.File)169 IOException (java.io.IOException)154 ArrayList (java.util.ArrayList)141 IPath (org.eclipse.core.runtime.IPath)138 IFile (org.eclipse.core.resources.IFile)130 Job (org.eclipse.core.runtime.jobs.Job)123 MultiStatus (org.eclipse.core.runtime.MultiStatus)113 InvocationTargetException (java.lang.reflect.InvocationTargetException)106 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)85 IProject (org.eclipse.core.resources.IProject)84 List (java.util.List)83 Path (org.eclipse.core.runtime.Path)52 Test (org.junit.Test)52 IResource (org.eclipse.core.resources.IResource)51 SubMonitor (org.eclipse.core.runtime.SubMonitor)51 Composite (org.eclipse.swt.widgets.Composite)44