org.eclipse.core.runtime.CoreException#getCause ( )源码实例Demo

下面列出了org.eclipse.core.runtime.CoreException#getCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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;
}
 
源代码2 项目: thym   文件: HybridProjectLaunchShortcut.java
private void launch(IProject project) {
	try {
		HybridProject hp = HybridProject.getHybridProject(project);
		if(!validateBuildToolsReady() 
				|| !shouldProceedWithLaunch(hp)
				|| !RequirementsUtility.checkCordovaRequirements() ){
			return;
		}
		ILaunchConfiguration launchConfig = findOrCreateLaunchConfiguration(project);
		ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
		updateLaunchConfiguration(wc);
		launchConfig = wc.doSave();
		DebugUITools.launch(launchConfig, "run");
		
	} catch (CoreException e) {
		if (e.getCause() instanceof IOException) {
			Status status = new Status(IStatus.ERROR, HybridUI.PLUGIN_ID,
					"Unable to complete the build for target plarform",
					e.getCause());
			StatusManager.handle(status);
		}else{
			StatusManager.handle(e);
		}
	}
}
 
源代码3 项目: saros   文件: InternalImpl.java
@Override
public void append(String projectName, String path, String content) throws RemoteException {
  log.trace(
      "appending content '"
          + content
          + "' to file '"
          + path
          + "' in project '"
          + projectName
          + "'");
  path = path.replace('\\', '/');

  IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getFile(path);

  try {
    file.appendContents(new ByteArrayInputStream(content.getBytes()), true, false, null);

  } catch (CoreException e) {
    log.error(e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}
 
源代码4 项目: saros   文件: InternalImpl.java
@Override
public void createFolder(String projectName, String path) throws RemoteException {

  path = path.replace('\\', '/');

  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

  try {

    String segments[] = path.split("/");
    IFolder folder = project.getFolder(segments[0]);
    log.trace(Arrays.asList(segments));
    if (!folder.exists()) folder.create(true, true, null);

    if (segments.length <= 1) return;

    for (int i = 1; i < segments.length; i++) {
      folder = folder.getFolder(segments[i]);
      if (!folder.exists()) folder.create(true, true, null);
    }

  } catch (CoreException e) {
    log.error(e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}
 
源代码5 项目: netbeans   文件: TestUtil.java
public static void handleException(Exception exception) throws Throwable {
        if (exception instanceof CoreException) {
            CoreException e = (CoreException) exception;
            IStatus status = e.getStatus();
            if (status instanceof RepositoryStatus) {
                RepositoryStatus rs = (RepositoryStatus) status;
                String html = rs.getHtmlMessage();
                if(html != null && !html.trim().equals("")) {
//                    HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault ();
//                    if (displayer != null) {
//                        displayer.showURL (url);
//                    } else {
//                        //LOG.info("No URLDisplayer found.");
//                    }

                    final HtmlPanel p = new HtmlPanel();
                    p.setHtml(html);
                    BugzillaUtil.show(p, "html", "ok");
                }
                throw new Exception(rs.getHtmlMessage());
            }
            if (e.getStatus().getException() != null) {
                throw e.getStatus().getException();
            }
            if (e.getCause() != null) {
                throw e.getCause();
            }
            throw e;
        }
        exception.printStackTrace();
        throw exception;
    }
 
源代码6 项目: saros   文件: InternalImpl.java
@Override
public void createFile(String projectName, String path, int size, boolean compressAble)
    throws RemoteException {

  log.trace(
      "creating file in project '"
          + projectName
          + "', path '"
          + path
          + "' size: "
          + size
          + ", compressAble="
          + compressAble);

  path = path.replace('\\', '/');

  int idx = path.lastIndexOf('/');

  if (idx != -1) createFolder(projectName, path.substring(0, idx));

  IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getFile(path);

  try {
    file.create(new GeneratingInputStream(size, compressAble), true, null);
  } catch (CoreException e) {
    log.error(e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}
 
源代码7 项目: saros   文件: InternalImpl.java
@Override
public void createProject(String projectName) throws RemoteException {

  log.trace("creating project: " + projectName);
  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
  try {
    project.create(null);
    project.open(null);
  } catch (CoreException e) {
    log.error("unable to create project '" + projectName + "' : " + e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}
 
源代码8 项目: saros   文件: InternalImpl.java
@Override
public void changeProjectEncoding(String projectName, String charset) throws RemoteException {

  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

  try {
    project.setDefaultCharset(charset, null);
  } catch (CoreException e) {
    log.error(e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}
 
源代码9 项目: saros   文件: InternalImpl.java
@Override
public void changeFileEncoding(String projectName, String path, String charset)
    throws RemoteException {
  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

  IFile file = project.getFile(path);

  try {
    file.setCharset(charset, null);
  } catch (CoreException e) {
    log.error(e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}
 
源代码10 项目: goclipse   文件: EclipseUtils.java
public static CommonException createCommonException(CoreException ce) {
	return new CommonException(ce.getMessage(), ce.getCause());
}
 
源代码11 项目: saros   文件: InternalImpl.java
@Override
public void createJavaProject(String projectName) throws RemoteException {

  log.trace("creating java project: " + projectName);

  IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

  try {

    project.create(null);
    project.open(null);

    IProjectDescription description = project.getDescription();
    description.setNatureIds(new String[] {JavaCore.NATURE_ID});
    project.setDescription(description, null);

    IJavaProject javaProject = JavaCore.create(project);

    Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>();

    entries.add(JavaCore.newSourceEntry(javaProject.getPath().append("src"), new IPath[0]));

    IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();

    LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);

    for (LibraryLocation element : locations) {
      entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
    }

    javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);

  } catch (CoreException e) {
    log.error("unable to create java project '" + projectName + "' :" + e.getMessage(), e);
    throw new RemoteException(e.getMessage(), e.getCause());
  }
}