Java Code Examples for org.eclipse.core.runtime.CoreException#getStatus()
The following examples show how to use
org.eclipse.core.runtime.CoreException#getStatus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessRunner.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public IStatus run(IPath workingDirectory, Map<String, String> environment, char[] input, List<String> args, IProgressMonitor monitor) { try { // FIXME If the monitor is cancelled we should kill the process if it is blocked! Since it's in another // thread we should be able to do so! Process p = doRun(args, workingDirectory, environment, false, null, null); ProcessRunnable runnable = new SudoCommandProcessRunnable(p, monitor, true, input); Thread t = new Thread(runnable, "Runnable for " + args.get(0)); //$NON-NLS-1$ t.start(); t.join(); return runnable.getResult(); } catch (CoreException ce) { return ce.getStatus(); } catch (Exception e) { return new Status(Status.ERROR, CorePlugin.PLUGIN_ID, e.getMessage()); } }
Example 2
Source File: XbaseDocumentProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 3
Source File: JSMetadataLoader.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * rebuildProjectIndexes */ private void rebuildProjectIndexes() { Job job = new Job(Messages.JSMetadataLoader_Rebuilding_Project_Indexes) { @Override protected IStatus run(IProgressMonitor monitor) { IWorkspace ws = ResourcesPlugin.getWorkspace(); try { ws.build(IncrementalProjectBuilder.FULL_BUILD, monitor); } catch (final CoreException e) { return e.getStatus(); } return Status.OK_STATUS; } }; job.schedule(); }
Example 4
Source File: JavaDocLocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Handles the exception thrown from JDT Core when the attached Javadoc * cannot be retrieved due to accessibility issues or location URL issue. This exception is not * logged but the exceptions occurred due to other reasons are logged. * * @param e the exception thrown when retrieving the Javadoc fails * @return the String message for why the Javadoc could not be retrieved * @since 3.9 */ public static String handleFailedJavadocFetch(CoreException e) { IStatus status= e.getStatus(); if (JavaCore.PLUGIN_ID.equals(status.getPlugin())) { Throwable cause= e.getCause(); int code= status.getCode(); // See bug 120559, bug 400060 and bug 400062 if (code == IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT || (code == IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC && (cause instanceof FileNotFoundException || cause instanceof SocketException || cause instanceof UnknownHostException || cause instanceof ProtocolException))) return CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc; } JavaPlugin.log(e); return CorextMessages.JavaDocLocations_error_gettingJavadoc; }
Example 5
Source File: AppEngineStandardRuntimeChangeListener.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Override protected IStatus run(IProgressMonitor monitor) { try { AppEngineStandardFacet.installAppEngineFacet(facetedProject, false /* installDependentFacets */, monitor); return Status.OK_STATUS; } catch (CoreException ex1) { // Remove App Engine as primary runtime try { facetedProject.removeTargetedRuntime(newRuntime, monitor); return ex1.getStatus(); // Displays missing constraints that prevented facet installation } catch (CoreException ex2) { return StatusUtil.merge(ex1.getStatus(), ex2.getStatus()); } } }
Example 6
Source File: DirectoryHandlerV1.java From orion.server with Eclipse Public License 1.0 | 6 votes |
/** * Performs the actual modification corresponding to a POST request. All preconditions * are assumed to be satisfied. * @return <code>true</code> if the operation was successful, and <code>false</code> otherwise. */ private boolean performPost(HttpServletRequest request, HttpServletResponse response, JSONObject requestObject, IFileStore toCreate, int options) throws CoreException, IOException, ServletException { boolean isCopy = (options & CREATE_COPY) != 0; boolean isMove = (options & CREATE_MOVE) != 0; try { if (isCopy || isMove) return performCopyMove(request, response, requestObject, toCreate, isCopy, options); if (requestObject.optBoolean(ProtocolConstants.KEY_DIRECTORY)) toCreate.mkdir(EFS.NONE, null); else toCreate.openOutputStream(EFS.NONE, null).close(); } catch (CoreException e) { IStatus status = e.getStatus(); if (status != null && status.getCode() == EFS.ERROR_WRITE) { // Sanitize message, as it might contain the filepath. statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to create: " + toCreate.getName(), null)); return false; } throw e; } return true; }
Example 7
Source File: SaveToFileAction.java From eclipsegraphviz with Eclipse Public License 1.0 | 6 votes |
@Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask("saving image", 100); getJobManager().beginRule(AbstractGraphicalContentProvider.CONTENT_LOADING_RULE, monitor); try { IGraphicalContentProvider provider = (IGraphicalContentProvider) providerDefinition.getProvider(); Object input = providerDefinition.read(view.getSelectedFile()); provider.saveImage(Display.getDefault(), new Point(0, 0), input, path, fileFormat); } catch (CoreException e) { return e.getStatus(); } finally { getJobManager().endRule(AbstractGraphicalContentProvider.CONTENT_LOADING_RULE); monitor.done(); } return Status.OK_STATUS; }
Example 8
Source File: BugzillaExecutor.java From netbeans with Apache License 2.0 | 6 votes |
private static String getNotFoundError(CoreException ce) { IStatus status = ce.getStatus(); Throwable t = status.getException(); if(t instanceof UnknownHostException || // XXX maybe a different msg ? t instanceof SocketTimeoutException || t instanceof NoRouteToHostException || t instanceof ConnectException) { Bugzilla.LOG.log(Level.FINER, null, t); return NbBundle.getMessage(BugzillaExecutor.class, "MSG_HOST_NOT_FOUND"); // NOI18N } String msg = getMessage(ce); if(msg != null) { msg = msg.trim().toLowerCase(); if(HTTP_ERROR_NOT_FOUND.equals(msg)) { Bugzilla.LOG.log(Level.FINER, "returned error message [{0}]", msg); // NOI18N return NbBundle.getMessage(BugzillaExecutor.class, "MSG_HOST_NOT_FOUND"); // NOI18N } } return null; }
Example 9
Source File: ExternalFoldersManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected IStatus run(IProgressMonitor pm) { try { if (this.externalFolders == null) return Status.OK_STATUS; IPath externalPath = null; for (int index = 0; index < this.externalFolders.size(); index++ ) { if ((externalPath = (IPath)this.externalFolders.get(index)) != null) { IFolder folder = getFolder(externalPath); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=321358 if (folder != null) folder.refreshLocal(IResource.DEPTH_INFINITE, pm); } // Set the processed ones to null instead of removing the element altogether, // so that they will not be considered as duplicates. // This will also avoid elements being shifted to the left every time an element // is removed. However, there is a risk of Collection size to be increased more often. this.externalFolders.setElementAt(null, index); } } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; }
Example 10
Source File: ExceptionHandler.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void perform(CoreException e, Shell shell, String title, String message) { JavaPlugin.log(e); IStatus status= e.getStatus(); if (status != null) { ErrorDialog.openError(shell, title, message, status); } else { displayMessageDialog(e.getMessage(), shell, title, message); } }
Example 11
Source File: ApplicationFileStore.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public IStatus build(IPath buildPath, IProgressMonitor monitor) { IPath applicationFolderPath = buildPath.append("application"); IFolder applicationFolder = getRepository().getProject() .getFolder(applicationFolderPath.makeRelativeTo(getRepository().getProject().getLocation())); if (!applicationFolder.exists()) { try { applicationFolder.create(true, true, new NullProgressMonitor()); getResource().copy(applicationFolder.getFile(getName()).getFullPath(), false, new NullProgressMonitor()); } catch (CoreException e) { return e.getStatus(); } } return Status.OK_STATUS; }
Example 12
Source File: RestoreProjectListener.java From thym with Eclipse Public License 1.0 | 5 votes |
@Override public IStatus run(IProgressMonitor monitor) { HybridProject hybridProject = HybridProject.getHybridProject(project); if(hybridProject != null){ try{ //do not call prepare for project with no engines otherwise cordova will complain if(hybridProject.getEngineManager().hasActiveEngine()) { hybridProject.prepare(monitor); } }catch(CoreException e){ return e.getStatus(); } } return Status.OK_STATUS; }
Example 13
Source File: DebugUtil.java From corrosion with Eclipse Public License 2.0 | 5 votes |
/** * Extracts an error message that can be presented to the user from an exception * when trying to execute GDB via CDT tooling. * * @param e exception thrown when trying to exceute GDB * @return error message that can be presented to user */ /* package */ static String getMessageFromGdbExecutionException(CoreException e) { final IStatus status = e.getStatus(); final String statusMessage = status.getMessage(); final Throwable statusException = status.getException(); if (statusException != null) { String exceptionMessage = statusException.getLocalizedMessage(); return NLS.bind(Messages.RustDebugTabGroup_gdbErrorMsg, statusMessage, exceptionMessage); } // else return statusMessage; }
Example 14
Source File: StandardFacetInstallDelegate.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override protected IStatus run(IProgressMonitor monitor) { try { AppEngineStandardFacet.installAllAppEngineRuntimes(facetedProject, monitor); return Status.OK_STATUS; } catch (CoreException ex) { return ex.getStatus(); } }
Example 15
Source File: BugzillaExecutor.java From netbeans with Apache License 2.0 | 5 votes |
static String getMessage(CoreException ce) { String msg = ce.getMessage(); if(msg != null && !msg.trim().equals("")) { // NOI18N return msg; } IStatus status = ce.getStatus(); msg = status != null ? status.getMessage() : null; return msg != null ? msg.trim() : null; }
Example 16
Source File: MarkerUtil.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Create an Eclipse marker for given BugInstance. * * @param javaProject * the project * @param monitor */ public static void createMarkers(final IJavaProject javaProject, final SortedBugCollection theCollection, final ISchedulingRule rule, IProgressMonitor monitor) { if (monitor.isCanceled()) { return; } final List<MarkerParameter> bugParameters = createBugParameters(javaProject, theCollection, monitor); if (monitor.isCanceled()) { return; } WorkspaceJob wsJob = new WorkspaceJob("Creating SpotBugs markers") { @Override public IStatus runInWorkspace(IProgressMonitor monitor1) throws CoreException { IProject project = javaProject.getProject(); try { new MarkerReporter(bugParameters, theCollection, project).run(monitor1); } catch (CoreException e) { FindbugsPlugin.getDefault().logException(e, "Core exception on add marker"); return e.getStatus(); } return monitor1.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS; } }; wsJob.setRule(rule); wsJob.setSystem(true); wsJob.setUser(false); wsJob.schedule(); }
Example 17
Source File: TestEditor.java From ermaster-b with Apache License 2.0 | 5 votes |
protected void validateState(IEditorInput input) { IDocumentProvider provider = getDocumentProvider(); if (!(provider instanceof IDocumentProviderExtension)) return; IDocumentProviderExtension extension = (IDocumentProviderExtension) provider; try { extension.validateState(input, getSite().getShell()); } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID); ILog log = Platform.getLog(bundle); log.log(x.getStatus()); Shell shell = getSite().getShell(); String title = "EditorMessages.Editor_error_validateEdit_title"; String msg = "EditorMessages.Editor_error_validateEdit_message"; ErrorDialog.openError(shell, title, msg, x.getStatus()); } return; } if (fSourceViewer != null) fSourceViewer.setEditable(isEditable()); }
Example 18
Source File: CtfTmfTraceTrimmingTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Test setup * * @throws IOException * failed to load the file * @throws TmfTraceException * failed to load the trace */ @Before public void setup() throws IOException, TmfTraceException { fOriginalTrace = CtfTmfTestTraceUtils.getTrace(fTestTrace); openTrace(fOriginalTrace); TmfTimeRange traceCutRange = getTraceCutRange(fOriginalTrace); assertNotNull(traceCutRange); fRequestedTraceCutRange = traceCutRange; ITmfTimestamp requestedTraceCutEnd = traceCutRange.getEndTime(); ITmfTimestamp requestedTraceCutStart = traceCutRange.getStartTime(); assertTrue(fOriginalTrace.getTimeRange().contains(traceCutRange)); TmfTimeRange range = new TmfTimeRange( requestedTraceCutStart, requestedTraceCutEnd); try { /* Perform the trim to create the new trace */ Path newTracePath = Files.createTempDirectory("trimmed-trace-test" + fTestTrace.name()); fNewTracePath = newTracePath; assertNotNull(newTracePath); fNewTracePath.toFile().delete(); fOriginalTrace.trim(range, newTracePath, new NullProgressMonitor()); /* Initialize the new trace */ fNewTrace = new CtfTmfTrace(); fNewTrace.initTrace(null, newTracePath.toString(), CtfTmfEvent.class); openTrace(fNewTrace); } catch (CoreException e) { /* * CoreException are more or less useless, all the interesting stuff is in their * "status" objects. */ String msg; IStatus status = e.getStatus(); IStatus[] children = status.getChildren(); if (children == null) { msg = status.getMessage(); } else { msg = Arrays.stream(children) .map(IStatus::getMessage) .collect(Collectors.joining("\n")); } fail(msg); } }
Example 19
Source File: IndexFilterManager.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * commitFilteredItems */ public void commitFilteredItems() { // build a preference value of all file stores we are filtering List<String> uris = CollectionsUtil.map(_filteredItems, new IMap<IFileStore, String>() { public String map(IFileStore item) { URI uri = item.toURI(); return uri.toString(); } }); String value = StringUtil.join(ITEM_DELIMITER, uris); // now save the file store list IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(IndexPlugin.PLUGIN_ID); prefs.put(IPreferenceConstants.FILTERED_INDEX_URIS, value); try { prefs.flush(); } catch (BackingStoreException e1) { // ignore } // determine which file stores were added and deleted Collection<IFileStore> nonOverlapping = CollectionsUtil.getNonOverlapping(loadFilteredItems(), _filteredItems); // determine which projects have been affected by the last set of changes Set<IProject> projects = new HashSet<IProject>(nonOverlapping.size()); for (IFileStore f : nonOverlapping) { IResource resource = (IResource) f.getAdapter(IResource.class); if (resource != null) { projects.add(resource.getProject()); } } // update project indexes that were affected by our changes for (final IProject p : projects) { Job job = new Job(MessageFormat.format(Messages.IndexFilterManager_Rebuilding_0, p.getName())) { protected IStatus run(IProgressMonitor monitor) { try { p.build(IncrementalProjectBuilder.FULL_BUILD, monitor); } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; } }; job.schedule(); } }
Example 20
Source File: ProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * @generated */ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); IEditorInput input = getEditorInput(); SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } dialog.create(); IDocumentProvider provider = getDocumentProvider(); if (provider == null) { // editor has been programmatically closed while the dialog was open return; } if (provider.isDeleted(input) && original != null) { String message = NLS.bind(Messages.ProcessDiagramEditor_SavingDeletedFile, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) { progressMonitor.setCanceled(true); } return; } IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IFile file = workspaceRoot.getFile(filePath); final IEditorInput newInput = new FileEditorInput(file); // Check if the editor is already open IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy(); IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { if (matchingStrategy.matches(editorRefs[i], newInput)) { MessageDialog.openWarning(shell, Messages.ProcessDiagramEditor_SaveAsErrorTitle, Messages.ProcessDiagramEditor_SaveAsErrorMessage); return; } } boolean success = false; try { provider.aboutToChange(newInput); getDocumentProvider(newInput).saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); success = true; } catch (CoreException x) { IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { ErrorDialog.openError(shell, Messages.ProcessDiagramEditor_SaveErrorTitle, Messages.ProcessDiagramEditor_SaveErrorMessage, x.getStatus()); } } finally { provider.changed(newInput); if (success) { setInput(newInput); } } if (progressMonitor != null) { progressMonitor.setCanceled(!success); } }