Refine search
if (!path.toFile().exists()) { String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString()); throw new CoreException(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, 1, msg, null)); input = new BufferedInputStream(new FileInputStream(path.toFile())); service.importPreferences(input); } catch (FileNotFoundException e) { String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString()); throw new CoreException(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, 1, msg, e)); } finally { if (input != null)
/** * Logs performance event failures to the platform's performance log */ private void logFailure(PerformanceStats stats, String pluginId, long elapsed) { //may have failed to get the performance log service if (log == null) return; if (pluginId == null) pluginId = Platform.PI_RUNTIME; String msg = "Performance failure: " + stats.getEvent() + " blame: " + stats.getBlameString() + " context: " + stats.getContext() + " duration: " + elapsed; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ Status status = new Status(IStatus.WARNING, pluginId, 1, msg, new RuntimeException()); log.log(new FrameworkLogEntry(status, status.getPlugin(), status.getSeverity(), status.getCode(), status.getMessage(), 0, status.getException(), null)); }
// Connect your client mClient.connect(); // Define a title for your current page, shown in autocompletion UI final String TITLE = "My Title"; //Define an action Action viewAction = Action.newAction(Action.TYPE_VIEW, TITLE, MY_URI); // Call the App Indexing API view method PendingResult<Status> result = AppIndex.AppIndexApi.start(mClient, viewAction); result.setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { if (status.isSuccess()) { Log.d(TAG, "App Indexing API: Recorded view successfully."); } else { Log.e(TAG, "App Indexing API: There was an error recording the view." + status.toString()); } } });
/** * @param baseline the baseline that is disposed * @throws CoreException with the baseline disposed information */ protected void baselineDisposed(IApiBaseline baseline) throws CoreException { throw new CoreException(new Status(IStatus.ERROR, ApiPlugin.PLUGIN_ID, ApiPlugin.REPORT_BASELINE_IS_DISPOSED, NLS.bind(Messages.BundleApiComponent_baseline_disposed, baseline.getName()), null)); } }
private void error(String message) { if (status == null) { String msg = NLS.bind(Messages.exception_featureParse, url.toExternalForm()); status = new MultiStatus(Activator.ID, Constants.EXCEPTION_FEATURE_PARSE, msg, null); } status.add(new Status(IStatus.ERROR, Activator.ID, Constants.EXCEPTION_FEATURE_PARSE, message, null)); }
/** * @see ErrorHandler#fatalError(SAXParseException) */ @Override public void fatalError(SAXParseException error) throws SAXException { // ensure a null value is not passed as message to Status constructor (bug 42782) String message = error.getMessage(); if (project != null) message = NLS.bind(Messages.resources_readMeta, project.getName()); problems.add(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_READ_METADATA, message == null ? "" : message, error)); //$NON-NLS-1$ throw error; }
/** * Tries to delete the custom loader jar added to support serving projects directly * without publishing. Returns a warning if not successful. * * @param destDir destination directory containing the loader jar * @param serverId ID of the server from which to delete the jar * @return result of copy operation */ public static IStatus removeLoaderJar(IPath destDir, String serverId) { String loaderJar = "/" + serverId + ".loader.jar"; File loaderFile = destDir.append(loaderJar).toFile(); // If loader jar exists but is not successfully deleted, return warning if (loaderFile.exists() && !loaderFile.delete()) return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishCantDeleteLoaderJar, loaderFile.getPath()), null); return Status.OK_STATUS; } /**
public static File getLocalFile(IPath path) throws CoreException { File localFile = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource file = root.findMember(path); if (file != null) { // internal resource URI location; if (file.getType() != IResource.FILE || (location = file.getLocationURI()) == null) { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.bind(Messages.file_notFound, path.toString()), null)); } localFile = Util.toLocalFile(location, null/*no progress availaible*/); if (localFile == null) throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.bind(Messages.file_notFound, path.toString()), null)); } else { // external resource -> it is ok to use toFile() localFile= path.toFile(); } return localFile; }
@Override public IProjectDescription loadProjectDescription(IPath path) throws CoreException { IProjectDescription result = null; IOException e = null; try { result = new ProjectDescriptionReader().read(path); if (result != null) { // check to see if we are using in the default area or not. use java.io.File for // testing equality because it knows better w.r.t. drives and case sensitivity IPath user = path.removeLastSegments(1); IPath platform = getRoot().getLocation().append(result.getName()); if (!user.toFile().equals(platform.toFile())) result.setLocation(user); } } catch (IOException ex) { e = ex; } if (result == null || e != null) { String message = NLS.bind(Messages.resources_errorReadProject, path.toOSString()); IStatus status = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_READ_METADATA, message, e); throw new ResourceException(status); } return result; }
private void addToStatus(MultiStatus multiStatus, String defaultMessage, CoreException ex) { IStatus status= ex.getStatus(); String message= ex.getLocalizedMessage(); if (message == null || message.length() < 1) status= new Status(status.getSeverity(), status.getPlugin(), status.getCode(), defaultMessage, ex); multiStatus.add(status); } }
private static void updateContainerClasspath(IJavaProject jproject, IPath containerPath, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws CoreException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (container == null) { throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, "Container " + containerPath + " cannot be resolved", null)); //$NON-NLS-1$//$NON-NLS-2$ } IClasspathEntry[] entries= container.getClasspathEntries(); IClasspathEntry[] newEntries= new IClasspathEntry[entries.length]; for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; if (curr.getEntryKind() == newEntry.getEntryKind() && curr.getPath().equals(newEntry.getPath())) { newEntries[i]= getUpdatedEntry(curr, newEntry, changedAttributes, jproject); } else { newEntries[i]= curr; } } requestContainerUpdate(jproject, container, newEntries); monitor.worked(1); }
@Override public IStatus merge(OutputStream output, String outputEncoding, IStorage ancestor, IStorage target, IStorage other, IProgressMonitor monitor) throws CoreException { IStorageMerger merger = createDelegateMerger(target); if (merger == null) return new Status(IStatus.WARNING, TeamPlugin.ID, CONFLICT, Messages.DelegatingStorageMerger_0, null); if (ancestor == null && !merger.canMergeWithoutAncestor()) { return new Status(IStatus.WARNING, TeamPlugin.ID, CONFLICT, NLS.bind(Messages.MergeContext_1, new String[] { target.getFullPath().toString() }), null); } return merger.merge(output, outputEncoding, ancestor, target, other, monitor); }
/** * Private constructor to enforce singleton usage. */ private PerformanceStatsProcessor() { super("Performance Stats"); //$NON-NLS-1$ setSystem(true); setPriority(DECORATE); BundleContext context = PlatformActivator.getContext(); String filter = '(' + FrameworkLog.SERVICE_PERFORMANCE + '=' + Boolean.TRUE.toString() + ')'; Collection<ServiceReference<FrameworkLog>> references; FrameworkLog perfLog = null; try { references = context.getServiceReferences(FrameworkLog.class, filter); if (references != null && !references.isEmpty()) { //just take the first matching service perfLog = context.getService(references.iterator().next()); //make sure correct location is set IPath logLocation = Platform.getLogFileLocation(); logLocation = logLocation.removeLastSegments(1).append("performance.log"); //$NON-NLS-1$ perfLog.setFile(logLocation.toFile(), false); } } catch (Exception e) { IStatus error = new Status(IStatus.ERROR, Platform.PI_RUNTIME, 1, "Error loading performance log", e); //$NON-NLS-1$ InternalPlatform.getDefault().log(error); } //use the platform log if we couldn't create the performance log if (perfLog == null) perfLog = InternalPlatform.getDefault().getFrameworkLog(); log = perfLog; }
/** * Logs an exception */ protected synchronized void addException(String message) { if (errors == null) { String msg = Messages.WM_errors; errors = new MultiStatus(ResourcesPlugin.PI_RESOURCES, 1, msg, null); } errors.add(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, 1, message, null)); }
public static void log(Throwable e) { if (e instanceof InvocationTargetException) e = ((InvocationTargetException) e).getTargetException(); IStatus status = null; if (e instanceof CoreException) { status = ((CoreException) e).getStatus(); } else if (e.getMessage() != null) { status = new Status(IStatus.ERROR, ID, IStatus.OK, e.getMessage(), e); } if (status != null) getDefault().getLog().log(status); }
@Override public ILaunchConfigurationWorkingCopy newInstance(IContainer container, String name) throws CoreException { // validate the configuration name - see bug 275741 IPath path = new Path(name); if (container == null) { // not allowed to nest in sub directory when local if (path.segmentCount() > 1) { throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugCoreMessages.LaunchConfigurationType_2)); } } // validate the name (last segment) try { DebugPlugin.getDefault().getLaunchManager().isValidLaunchConfigurationName(path.lastSegment()); } catch (IllegalArgumentException e) { throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), e.getMessage(), e)); } return new LaunchConfigurationWorkingCopy(container, name, this); }