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