Search in sources :

Example 76 with IStatus

use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.

the class AutomaticUpdate method doUpdate.

private void doUpdate() {
    if (operation == null) {
        return;
    }
    IStatus status = operation.getResolutionResult();
    // user cancelled
    if (status.getSeverity() == IStatus.CANCEL)
        return;
    // Special case those statuses where we would never want to open a wizard
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
        return;
    }
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
        UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), operation, operation.getSelectedUpdates());
        TSWizardDialog dialog = new TSWizardDialog(getShell(), wizard);
        dialog.create();
        dialog.open();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) UpdateWizard(net.heartsome.cat.p2update.ui.UpdateWizard) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog)

Example 77 with IStatus

use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.

the class ImportProjectWizardPage method createProjects.

/**
	 * Create the selected projects
	 * 
	 * @return boolean <code>true</code> if all project creations were
	 * 	successful.
	 */
public boolean createProjects() {
    saveWidgetValues();
    final Object[] selected = projectsList.getCheckedElements();
    createdProjects = new ArrayList();
    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                //$NON-NLS-1$
                monitor.beginTask("", selected.length);
                if (monitor.isCanceled()) {
                    throw new OperationCanceledException();
                }
                for (int i = 0; i < selected.length; i++) {
                    createExistingProject((ProjectRecord) selected[i], new SubProgressMonitor(monitor, 1));
                }
            } finally {
                monitor.done();
            }
        }
    };
    // run the new project creation operation
    try {
        getContainer().run(true, true, op);
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        // one of the steps resulted in a core exception
        Throwable t = e.getTargetException();
        String message = DataTransferMessages.WizardExternalProjectImportPage_errorMessage;
        IStatus status;
        if (t instanceof CoreException) {
            status = ((CoreException) t).getStatus();
        } else {
            status = new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, 1, message, t);
        }
        ErrorDialog.openError(getShell(), message, null, status);
        return false;
    }
    ArchiveFileManipulations.closeStructureProvider(structureProvider, getShell());
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException)

Example 78 with IStatus

use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.

the class AbstractPortableURIsTest method appendLeafs.

protected void appendLeafs(IStatus status, StringBuilder result) {
    if (status.isOK()) {
        return;
    }
    result.append(status.getMessage()).append('\n');
    IStatus[] children = status.getChildren();
    for (IStatus child : children) {
        appendLeafs(child, result);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus)

Example 79 with IStatus

use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.

the class AbstractPortableURIsTest method doTestResource.

protected void doTestResource(String platformPath, String... packageNames) {
    Resource resource = resourceSet.getResource(URI.createPlatformPluginURI(platformPath, false), true);
    assertNotNull(resource);
    assertEquals(1, resource.getContents().size());
    EObject obj = resource.getContents().get(0);
    if (obj instanceof EPackage) {
        assertEquals(packageNames[0], ((EPackage) obj).getName());
    } else if (obj instanceof GenModel) {
        GenModel model = (GenModel) obj;
        List<GenPackage> packages = Lists.newArrayList(model.getGenPackages());
        assertEquals(packageNames.length, packages.size());
        ListExtensions.sortInplaceBy(packages, new Functions.Function1<GenPackage, String>() {

            @Override
            public String apply(GenPackage p) {
                return p.getEcorePackage().getName();
            }
        });
        List<String> packageNamesList = Arrays.asList(packageNames);
        Collections.sort(packageNamesList);
        for (int i = 0; i < packageNamesList.size(); i++) {
            assertEquals(packageNamesList.get(i), packages.get(i).getEcorePackage().getName());
        }
        IStatus status = model.validate();
        assertTrue(printLeafs(status), status.isOK());
        EObject orig = EcoreUtil.copy(obj);
        ((GenModel) obj).reconcile();
        if (!EcoreUtil.equals(orig, obj)) {
            Predicate<EStructuralFeature> ignoreContainer = new Predicate<EStructuralFeature>() {

                @Override
                public boolean apply(EStructuralFeature f) {
                    if (f instanceof EReference) {
                        EReference casted = (EReference) f;
                        return !casted.isContainment();
                    }
                    return false;
                }
            };
            String origAsString = EmfFormatter.objToStr(orig, ignoreContainer);
            String newAsString = EmfFormatter.objToStr(obj, ignoreContainer);
            throw new ComparisonFailure("Reconcile changed model", origAsString, newAsString);
        }
    } else {
        fail("Unexpected root element type: " + obj.eClass().getName());
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) GenPackage(org.eclipse.emf.codegen.ecore.genmodel.GenPackage) EPackage(org.eclipse.emf.ecore.EPackage) Predicate(com.google.common.base.Predicate) ComparisonFailure(org.junit.ComparisonFailure) EObject(org.eclipse.emf.ecore.EObject) GenModel(org.eclipse.emf.codegen.ecore.genmodel.GenModel) List(java.util.List) EReference(org.eclipse.emf.ecore.EReference)

Example 80 with IStatus

use of org.eclipse.core.runtime.IStatus in project xtext-eclipse by eclipse.

the class XtextDocumentProvider method setDocumentContent.

@Override
protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException {
    boolean result;
    try {
        if (isWorkspaceExternalEditorInput(editorInput)) {
            java.net.URI uri = ((IURIEditorInput) editorInput).getURI();
            try (InputStream contentStream = uri.toURL().openStream()) {
                setDocumentContent(document, contentStream, encoding);
                result = true;
            }
        } else {
            result = super.setDocumentContent(document, editorInput, encoding);
        }
        if (result)
            setDocumentResource((XtextDocument) document, editorInput, encoding);
        return result;
    } catch (IOException ex) {
        // $NON-NLS-1$
        String message = (ex.getMessage() != null ? ex.getMessage() : "");
        IStatus s = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, ex);
        throw new CoreException(s);
    } catch (CoreException ex) {
        if (ex.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) {
            return false;
        } else {
            throw ex;
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) IURIEditorInput(org.eclipse.ui.IURIEditorInput) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException)

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