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

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

源代码1 项目: tmxeditor8   文件: WordsFA.java
/**
 * 输出字数统计结果到结果窗体中
 * @param WordsFAResultMap
 */
public void printWordsFAReslut() {
	String htmlPath = createFAResultHtml();
	try {
		model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_INFINITE, null);
	} catch (CoreException e1) {
		e1.printStackTrace();
	}
	
	final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath));
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			try {
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true);
			} catch (PartInitException e) {
				logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log5"), e);
				e.printStackTrace();
			}
		}
	});
}
 
源代码2 项目: translationstudio8   文件: WordsFA.java
/**
 * 输出字数统计结果到结果窗体中
 * @param WordsFAResultMap
 */
public void printWordsFAReslut() {
	String htmlPath = createFAResultHtml();
	try {
		model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_INFINITE, null);
	} catch (CoreException e1) {
		e1.printStackTrace();
	}
	
	final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath));
	if (PlatformUI.getWorkbench().isClosing()) {
		return;
	}
	
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			try {
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true);
			} catch (PartInitException e) {
				logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log5"), e);
				e.printStackTrace();
			}
		}
	});
}
 
源代码3 项目: ice   文件: XMLPersistenceProviderTester.java
/**
 * This operation cleans up after the test and removes the project space.
 */
@AfterClass
static public void teardown() {

	// Delete the projects.
	try {
		project.delete(true, null);
		otherProject.delete(true, null);
	} catch (CoreException e) {
		// Complain
		e.printStackTrace();
	}

	// Stop the provider
	xmlpp.stop();

	return;
}
 
protected Set<IFile> getProjectStatechartInput(Diagram diagram) {
	final IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	final IProject project = file.getProject();
	final Set<IFile> result = new HashSet<IFile>();
	try {
		project.accept(new IResourceVisitor() {
			public boolean visit(IResource resource) throws CoreException {
				// TODO check for package explorer filters here
				if (resource.isHidden()) {
					return false;
				}
				if (resource instanceof IFile) {
					if (file.getFileExtension().equals(resource.getFileExtension()))
						result.add((IFile) resource);
				}
				return true;
			}
		});
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return result;
}
 
源代码5 项目: eclipse   文件: BazelProjectSupport.java
private static IProject createBaseProject(String projectName, URI location) {
  IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

  if (!newProject.exists()) {
    URI projectLocation = location;
    IProjectDescription desc =
        newProject.getWorkspace().newProjectDescription(newProject.getName());
    if (location != null
        && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) {
      projectLocation = null;
    }

    desc.setLocationURI(projectLocation);
    try {
      newProject.create(desc, null);
      if (!newProject.isOpen()) {
        newProject.open(null);
      }
    } catch (CoreException e) {
      e.printStackTrace();
    }
  }

  return newProject;
}
 
@SuppressWarnings("rawtypes")
public Object[] getElements(Object inputElement) {
	try {
		if (inputElement instanceof IContainer) {
			return filterForContent(((IContainer) inputElement).members());
		}
		if (inputElement instanceof Object[]) {
			return filterForContent((Object[]) inputElement);
		}
		if (inputElement instanceof Collection) {
			return filterForContent(((Collection) inputElement).toArray());
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return new Object[0];
}
 
@Override
public IPath getSourceMapFile(IPath tsFilePath) {
	// Search js file in the same folder than ts file.
	IPath jsMapFilePath = tsFilePath.removeFileExtension().addFileExtension("js.map");
	IFile jsMapFile = WorkbenchResourceUtil.findFileFromWorkspace(jsMapFilePath);
	if (jsMapFile != null) {
		return jsMapFilePath;
	}
	// Search js file in the well folder by using tsconfig.json
	IFile tsFile = WorkbenchResourceUtil.findFileFromWorkspace(tsFilePath);
	try {
		IDETsconfigJson tsconfig = TypeScriptResourceUtil.findTsconfig(tsFile);
		if (tsconfig != null) {
			IContainer configOutDir = tsconfig.getOutDir();
			if (configOutDir != null && configOutDir.exists()) {
				IPath tsFileNamePath = WorkbenchResourceUtil.getRelativePath(tsFile, configOutDir)
						.removeFileExtension();
				return tsFileNamePath.addFileExtension("js");
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
源代码8 项目: CodeCheckerEclipsePlugin   文件: PluginTest.java
/**
 * Import cpp project into workspace, and setup SWTBot.
 */
@BeforeClass
public static void setup() {

    bot = new SWTWorkbenchBot();

    Path file = null;
    try {
        file = Utils.loadFileFromBundle("org.codechecker.eclipse.rcp.it.tests", Utils.RES + CPP_PROJ);
    } catch (URISyntaxException | IOException e) {
        e.printStackTrace();
    }

    Utils.copyFolder(file,
            Paths.get(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separator));

    File project = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separator
            + CPP_PROJ + File.separator + ".project");
    try {
        ProjectImporter.importProject(project.toPath(), CPP_PROJ);
    } catch (CoreException e1) {
        e1.printStackTrace();
    }
}
 
源代码9 项目: gef   文件: SyncGraphvizExportHandler.java
@Override
public boolean visit(final IResourceDelta delta) {
	IResource resource = delta.getResource();
	if (resource.getType() == IResource.FILE
			&& ((IFile) resource).getName().endsWith(EXTENSION)) {
		try {
			IWorkspace workspace = ResourcesPlugin.getWorkspace();
			if (!workspace.isTreeLocked()) {
				IFile file = (IFile) resource;
				workspace.run(new DotExportRunnable(file), null);
			}
		} catch (CoreException e) {
			e.printStackTrace();
		}
	}
	return true;
}
 
源代码10 项目: developer-studio   文件: WebUtils.java
public static boolean isDynamicWebProject(IProject containerProject) {
	boolean isWebProject = false;
	try {
		if (containerProject.isOpen()) {
			for (String natureId : containerProject.getDescription().getNatureIds()) {
				isWebProject = natureId.startsWith("org.eclipse.wst");
				if (isWebProject) {
					break;
				}
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return isWebProject;
}
 
源代码11 项目: scava   文件: LaunchEvent.java
public LaunchEvent(ILaunch launch) {
	this.launch = launch;

	ILaunchConfiguration launchConfiguration = launch.getLaunchConfiguration();
	try {
		IResource[] mappedResources = launchConfiguration.getMappedResources();
		for (IResource iResource : mappedResources) {
			launchedFile = iResource.getName();
			launchedProject = iResource.getProject();
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
}
 
源代码12 项目: ice   文件: VibeLauncherBuilderTester.java
/**
 * <p>
 * A utility operation that sets up the IProject space for the tests. It
 * creates a CaebatTesterWorkspace for the launcher to be built in.
 * </p>
 */
private void setupIProject() {
	URI defaultProjectLocation = null;
	String separator = System.getProperty("file.separator");

	try {
		// Get the project handle
		IProject project = projectSpace;
		// If the project does not exist, create it
		if (!project.exists()) {
			// Set the location as ${workspace_loc}/ItemTesterWorkspace
			defaultProjectLocation = (new File(
					System.getProperty("user.home") + separator
							+ "ICETests" + separator
							+ "caebatTesterWorkspace")).toURI();
			// Create the project description
			IProjectDescription desc = ResourcesPlugin.getWorkspace()
					.newProjectDescription("caebatTesterWorkspace");
			// Set the location of the project
			desc.setLocationURI(defaultProjectLocation);
			// Create the project
			project.create(desc, null);
		}
		// Open the project if it is not already open
		if (project.exists() && !project.isOpen()) {
			project.open(null);
		}
	} catch (CoreException e) {
		// Catch for creating the project
		e.printStackTrace();
		fail();
	}

}
 
源代码13 项目: CodeCheckerEclipsePlugin   文件: AnalysisTest.java
/**
 * Import project - Set nature.
 */
@BeforeClass
public static void setUpBeforeClass() {
    bot = new SWTWorkbenchBot();

    // Import project
    Path file = null;
    try {
        file = Utils.loadFileFromBundle("org.codechecker.eclipse.rcp.it.tests", Utils.RES + CPP_PROJ);
    } catch (URISyntaxException | IOException e) {
        e.printStackTrace();
    }

    Utils.copyFolder(file,
            Paths.get(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separator));

    File projectFile = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separator
            + CPP_PROJ + File.separator + GuiUtils.DOT_PROJECT);
    try {
        ProjectImporter.importProject(projectFile.toPath(), CPP_PROJ);
    } catch (CoreException e1) {
        e1.printStackTrace();
    }

    // Add CodeChecker Nature.
    project = bot.tree().getTreeItem(CPP_PROJ);
    project.contextMenu(GuiUtils.ADD_NATURE_MENU).click();
}
 
源代码14 项目: ice   文件: VibeLauncherTester.java
/**
 * Clean up after ourselves
 */
@AfterClass
public static void cleanup() {
	try {
		projectSpace.close(null);
		projectSpace.delete(true, null);
	} catch (CoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		fail("VIBE Launcher Tester: Error!  Could not clean up project space.");
	}
}
 
源代码15 项目: aCute   文件: DotnetTestDelegate.java
private ILaunchConfiguration getLaunchConfiguration(String mode, IResource resource) {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType configType = launchManager
			.getLaunchConfigurationType("org.eclipse.acute.dotnettest.DotnetTestDelegate"); //$NON-NLS-1$
	try {
		ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(configType);

		String configName;
		if (resource.getLocation().toFile().isFile()) {
			configName = NLS.bind(Messages.DotnetTestDelegate_configuration, resource.getParent().getName() + "." + resource.getName()); //$NON-NLS-1$
		} else {
			configName = NLS.bind(Messages.DotnetTestDelegate_configuration, resource.getName());
		}

		for (ILaunchConfiguration iLaunchConfiguration : launchConfigurations) {
			if (iLaunchConfiguration.getName().equals(configName)
					&& iLaunchConfiguration.getModes().contains(mode)) {
				return iLaunchConfiguration;
			}
		}
		configName = launchManager.generateLaunchConfigurationName(configName);
		ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, configName);
		if (resource.getLocation().toFile().isFile()) {
			if (resource.getFileExtension().equals("cs")) { //$NON-NLS-1$
				wc.setAttribute(TEST_SELECTION_TYPE, SELECTED_TEST);
				wc.setAttribute(TEST_CLASS, resource.getName().replaceFirst("\\.cs$", "")); //$NON-NLS-1$ //$NON-NLS-2$
			}
			resource = resource.getParent();
		}
		wc.setAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, resource.getLocation().toString());

		return wc;
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
源代码16 项目: xds-ide   文件: SearchWholeWordAction.java
@Override
public void run(IAction action) {
   	final String pattern = getPattern();
   	if (pattern.isEmpty()) {
   		return;
   	}
       
       try {
       	ISearchQuery query = TextSearchQueryProvider.getPreferred().createQuery(new TextSearchInput() {
			
			@Override
			public boolean isRegExSearch() {
				return true;
			}
			
			@Override
			public boolean isCaseSensitiveSearch() {
				return true;
			}
			
			@Override
			public String getSearchText() {
				return pattern;
			}
			
			@Override
			public FileTextSearchScope getScope() {
				return SearchWholeWordAction.this.getScope(); //$NON-NLS-1$
			}
		});
       	NewSearchUI.runQueryInBackground(query);
	} catch (CoreException e) {
		e.printStackTrace();
	}
       
	return;
}
 
源代码17 项目: ice   文件: VibeKVPairTester.java
/**
 * <p>
 * This operation sets up the workspace.
 * </p>
 */
@BeforeClass
public static void beforeTests() {

	// Local Declarations
	IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = null;
	String separator = System.getProperty("file.separator");
	String userDir = System.getProperty("user.home") + separator
			+ "ICETests" + separator + "caebatTesterWorkspace";
	// Enable Debugging
	System.setProperty("DebugICE", "");

	// Setup the project
	try {
		// Get the project handle
		IPath projectPath = new Path(userDir + separator + ".project");
		// Create the project description
		IProjectDescription desc = ResourcesPlugin.getWorkspace()
				.loadProjectDescription(projectPath);
		// Get the project handle and create it
		project = workspaceRoot.getProject(desc.getName());
		// Create the project if it doesn't exist
		if (!project.exists()) {
			project.create(desc, new NullProgressMonitor());
		}
		// Open the project if it is not already open
		if (project.exists() && !project.isOpen()) {
			project.open(new NullProgressMonitor());
		}
		// Refresh the workspace
		project.refreshLocal(IResource.DEPTH_INFINITE, null);
	} catch (CoreException e) {
		// Catch exception for creating the project
		e.printStackTrace();
		fail();
	}

	// Set the global project reference.
	projectSpace = project;

	return;
}
 
源代码18 项目: ice   文件: INIWriterTester.java
/**
 * 
 */
@BeforeClass
public static void beforeTests() {

	// Local Declarations
	IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = null;
	String separator = System.getProperty("file.separator");
	String userDir = System.getProperty("user.home") + separator
			+ "ICETests" + separator + "ioTesterWorkspace";
	// Enable Debugging
	System.setProperty("DebugICE", "");

	// Setup the project
	try {
		// Get the project handle
		IPath projectPath = new Path(userDir + separator + ".project");
		// Create the project description
		IProjectDescription desc = ResourcesPlugin.getWorkspace()
				.loadProjectDescription(projectPath);
		// Get the project handle and create it
		project = workspaceRoot.getProject(desc.getName());
		// Get the project handle and create it
		project = workspaceRoot.getProject(desc.getName());
		// Create the project if it doesn't exist
		if (!project.exists()) {
			project.create(desc, new NullProgressMonitor());
		}
		// Open the project if it is not already open
		if (project.exists() && !project.isOpen()) {
			project.open(new NullProgressMonitor());
		}
		// Refresh the workspace
		project.refreshLocal(IResource.DEPTH_INFINITE, null);
	} catch (CoreException e) {
		// Catch exception for creating the project
		e.printStackTrace();
		fail();
	}

	// Set the global project reference.
	projectSpace = project;

	return;
}
 
源代码19 项目: ice   文件: INIReaderTester.java
/**
 * 
 */
@BeforeClass
public static void beforeTests() {

	// Local Declarations
	IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = null;
	String separator = System.getProperty("file.separator");
	String userDir = System.getProperty("user.home") + separator
			+ "ICETests" + separator + "ioTesterWorkspace";
	// Enable Debugging
	System.setProperty("DebugICE", "");

	// Setup the project
	try {
		// Get the project handle
		IPath projectPath = new Path(userDir + separator + ".project");
		// Create the project description
		IProjectDescription desc = ResourcesPlugin.getWorkspace()
		                    .loadProjectDescription(projectPath);
		// Get the project handle and create it
		project = workspaceRoot.getProject(desc.getName());
		// Get the project handle and create it
		project = workspaceRoot.getProject(desc.getName());
		// Create the project if it doesn't exist
		if (!project.exists()) {
			project.create(desc, new NullProgressMonitor());
		}
		// Open the project if it is not already open
		if (project.exists() && !project.isOpen()) {
		   project.open(new NullProgressMonitor());
		}
		// Refresh the workspace
		project.refreshLocal(IResource.DEPTH_INFINITE, null);
	} catch (CoreException e) {
		// Catch exception for creating the project
		e.printStackTrace();
		fail();
	}

	// Set the global project reference.
	projectSpace = project;

	return;
}
 
源代码20 项目: ice   文件: ICEFormEditor.java
/**
 * This operation overrides init so that the ICE Form, passed as an
 * IEditorInput, can be stored.
 * 
 * @param site
 *            the site on the workbench where the Form is drawn
 * @param input
 *            the input for this editor
 */
@Override
public void init(IEditorSite site, IEditorInput input)
		throws RuntimeException {

	// Get the E4 Context. This is how you get into the E4 application model
	// if you are running from a 3.x part and don't have your own
	// application model. See bugs.eclipse.org/bugs/show_bug.cgi?id=376486
	// and chapter 101 of Lar Vogel's e4 book.
	e4Context = site.getService(IEclipseContext.class);

	// Instruct the framework to perform dependency injection for
	// this Form using the ContextInjectionFactory.
	ContextInjectionFactory.inject(this, e4Context);

	// Get the Client Reference
	IClient client = null;
	try {
		client = IClient.getClient();
	} catch (CoreException e1) {
		e1.printStackTrace();
	}

	// Set the site
	setSite(site);

	// Grab the form from the input or the client depending on the type of
	// the input. This should only be a temporary switch until we remove the
	// ICEFormInput and redirect the way the client works.
	if (input instanceof ICEFormInput) {
		ICEFormInput = (ICEFormInput) input;
		iceDataForm = ICEFormInput.getForm();

		// Set the part name to be the file name
		setPartName(iceDataForm.getName() + ".xml");

		// Set the input
		setInput(input);
	} else if (input instanceof FileEditorInput && client != null) {
		// Grab the file and load the form
		IFile formFile = ((FileEditorInput) input).getFile();
		// try {
		// IClient client = IClient.getClient();
		iceDataForm = client.loadItem(formFile);
		logger.info("IClient and Form loaded.");
		// Set *correct* input via a little short circuit.
		ICEFormInput = new ICEFormInput(iceDataForm);
		setInput(ICEFormInput);

		// Set the IFormWidget on the IClient
		client.addFormWidget(new EclipseFormWidget(this));

		// Set the part name to be the file name
		setPartName(input.getName());

		// Register the client as a listener
		// of specific form editor events.
		try {
			registerUpdateListener(
					IUpdateEventListener.getUpdateEventListener());
			registerProcessListener(
					IProcessEventListener.getProcessEventListener());
			registerResourceProvider(
					ISimpleResourceProvider.getSimpleResourceProvider());
		} catch (CoreException e) {
			// Complain
			logger.error(
					"Unable to get register the update, process, or simpleresource implementations!",
					e);
		}

	} else {
		// Throw errors if the type is wrong
		logger.error("Unable to load Form Editor!");
		throw new RuntimeException("Input passed to ICEFormEditor.init()"
				+ " is not of type ICEFormInput or FileEditorInput, or the IClient instance is null.");
	}

	// Get the Item Name for the Form Header.
	for (Identifiable i : client.getItems()) {
		if (iceDataForm.getItemID() == i.getId()) {
			itemName = i.getClass().getSimpleName() + " Item " + i.getId();
			break;
		}
	}

	// Register this ICEFormEditor with the provided Form
	iceDataForm.register(this);

	return;
}