本文整理匯總了Java中org.eclipse.core.resources.ResourcesPlugin類的典型用法代碼示例。如果您正苦於以下問題:Java ResourcesPlugin類的具體用法?Java ResourcesPlugin怎麽用?Java ResourcesPlugin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ResourcesPlugin類屬於org.eclipse.core.resources包,在下文中一共展示了ResourcesPlugin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupWorkspace
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* Loads (and indexes) all the required external libraries. Also imports all the workspace projects.
*/
@Before
public void setupWorkspace() throws Exception {
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
assertTrue("Expected empty workspace. Projects were in workspace: " + Arrays.toString(projects),
0 == projects.length);
final URI externalRootLocation = getResourceUri(PROBANDS, EXT_LOC);
externalLibraryPreferenceStore.add(externalRootLocation);
final IStatus result = externalLibraryPreferenceStore.save(new NullProgressMonitor());
assertTrue("Error while saving external library preference changes.", result.isOK());
waitForAutoBuild();
for (final String projectName : ALL_PROJECT_IDS) {
final File projectsRoot = new File(getResourceUri(PROBANDS, WORKSPACE_LOC));
ProjectUtils.importProject(projectsRoot, projectName);
}
waitForAutoBuild();
}
示例2: testWorkspaceProjectHidingExternalProject_after
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* Check if index is populated only with workspace project content when the external location with single project is
* registered and workspace contains project with the same name. External library is registered before project is
* created in the workspace.
*/
public void testWorkspaceProjectHidingExternalProject_after() throws Exception {
IProject createJSProject = ProjectUtils.createJSProject("LibFoo");
IFolder src = configureProjectWithXtext(createJSProject);
IFile manifest = createJSProject.getProject().getFile("manifest.n4mf");
assertMarkers("manifest of first project should have no errors", manifest, 0);
createTestFile(src, "Foo", "console.log('hi')");
createTestFile(src, "AAAA", "console.log('hi')");
createTestFile(src, "BBB", "console.log('hi')");
waitForAutoBuild();
copyProjectsToLocation(externalLibrariesRoot, "LibFoo");
setExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot);
Collection<String> expectedWorkspace = collectIndexableFiles(ResourcesPlugin.getWorkspace());
assertResourceDescriptions(expectedWorkspace, BuilderUtil.getAllResourceDescriptions());
removeExternalLibrariesPreferenceStoreLocations(externalLibraryPreferenceStore, externalLibrariesRoot);
}
示例3: locateUnit
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
public static UnitLocation locateUnit(VFUnit unit) throws CoreException, IOException {
VFClass vfClass = unit.getVfMethod().getVfClass();
String className = vfClass.getSootClass().getName();
String projectName = GlobalSettings.get("AnalysisProject");
IPath path = new Path("/sootOutput/" + className + ".jimple");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
File file = project.getFile(path).getLocation().toFile();
List<String> lines = Files.readAllLines(file.toPath());
// determine method offset
int[] methodPosition = find(lines, unit.getVfMethod().getSootMethod().getDeclaration(), 0);
String toFind = unit.getUnit().toString() + ";";
int[] position = find(lines, toFind, methodPosition[1]);
UnitLocation location = new UnitLocation();
location.jimpleFile = path;
location.charStart = position[0];
location.charEnd = position[1];
location.line = position[2];
location.project = project;
location.vfUnit = unit;
return location;
}
示例4: loadBuildProperties
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
private void loadBuildProperties() {
String buildPropFilePath = buildPropFilePath();
IPath bldPropPath = new Path(buildPropFilePath);
IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(bldPropPath);
try {
InputStream reader = iFile.getContents();
buildProps.load(reader);
} catch (CoreException | IOException e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
"Exception occurred while loading build properties from file -\n" + e.getMessage());
}
Enumeration<?> propertyNames = buildProps.propertyNames();
populateTextBoxes(propertyNames);
}
示例5: getLogicalSystemDefinition
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
public LogicalSystemNode getLogicalSystemDefinition(String name, String containerName) {
LogicalSystemNode ret = null;
if (containerName != null) {
String[] names = StringUtils.split(containerName, "/");
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = wsRoot.findMember(new Path("/" + names[0]));
IPath loc = resource.getLocation();
File file = new File(loc.toOSString() + File.separator + name + ".lsys");
try {
ret = ParseUtil.getLogicalSystemNodeFromText(FileUtils.readFileToString(file));
} catch (IOException e) {
EclipseUtil.writeStactTraceToConsole(e);
}
}
return ret;
}
示例6: dispose
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void dispose() {
updateProblemIndication = false;
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
getSite().getPage().removePartListener(partListener);
adapterFactory.dispose();
if (getActionBarContributor().getActiveEditor() == this) {
getActionBarContributor().setActiveEditor(null);
}
for (PropertySheetPage propertySheetPage : propertySheetPages) {
propertySheetPage.dispose();
}
if (contentOutlinePage != null) {
contentOutlinePage.dispose();
}
super.dispose();
}
示例7: getElements
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
@Override
public IAdaptable[] getElements() {
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
final IProject[] elements = new IProject[projects.length];
int elementCount = 0;
for (int i = 0, size = projects.length; i < size; i++) {
final IProject project = projects[i];
final IN4JSProject n4Project = core.findProject(toUri(project)).orNull();
if (type == null) { // Other Projects
if (n4Project == null || !n4Project.exists()) {
elements[elementCount++] = project;
}
} else {
if (n4Project != null && n4Project.exists() && type.equals(n4Project.getProjectType())) {
elements[elementCount++] = project;
}
}
}
return Arrays.copyOfRange(elements, 0, elementCount);
}
示例8: close
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* Closes a project.
*
* @return <code>false</code> if the close process has been canceled by user.
*/
public boolean close() {
// close opened editors
closeAllEditors();
// save project and copy temporary files to project files
boolean bRet = save(true);
if (bRet) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
// clear Source picker view if needed
clearSourcePickerView();
Engine.theApp.databaseObjectsManager.clearCache(getObject());
}
return bRet;
}
示例9: doSaveAs
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* This also changes the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void doSaveAs ()
{
SaveAsDialog saveAsDialog = new SaveAsDialog ( getSite ().getShell () );
saveAsDialog.open ();
IPath path = saveAsDialog.getResult ();
if ( path != null )
{
IFile file = ResourcesPlugin.getWorkspace ().getRoot ().getFile ( path );
if ( file != null )
{
doSaveAs ( URI.createPlatformResourceURI ( file.getFullPath ().toString (), true ), new FileEditorInput ( file ) );
}
}
}
示例10: dialogChanged
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* This method ensures user select Target project and permissions
*/
private void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot()
.findMember(new Path(getContainerName().get("TargetPath")));
if (getContainerName().get("TargetPath").length() == 0) {
updateStatus("File container must be specified");
return;
}
if (container == null
|| (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
updateStatus("File container must exist");
return;
}
if (!container.isAccessible()) {
updateStatus("Project must be writable");
return;
}
updateStatus(null);
}
示例11: createSubjobInSpecifiedFolder
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* @param subJobXMLPath
* @param parameterFilePath
* @param parameterFile
* @param subJobFile
* @param importFromPath
* @param subjobPath
* @return
* @throws InstantiationException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
* @throws JAXBException
* @throws ParserConfigurationException
* @throws SAXException
* @throws IOException
* @throws CoreException
* @throws FileNotFoundException
*/
public static Container createSubjobInSpecifiedFolder(IPath subJobXMLPath, IPath parameterFilePath, IFile parameterFile,
IFile subJobFile, IPath importFromPath,String subjobPath) throws InstantiationException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException, JAXBException, ParserConfigurationException,
SAXException, IOException, CoreException, FileNotFoundException {
UiConverterUtil converterUtil = new UiConverterUtil();
Object[] subJobContainerArray=null;
IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(subJobXMLPath);
File file = new File(xmlFile.getFullPath().toString());
if (file.exists()) {
subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(), subJobFile, parameterFile,true);
} else {
IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(parameterFilePath.segment(1));
IFolder iFolder = iProject.getFolder(subjobPath.substring(0, subjobPath.lastIndexOf('/')));
if (!iFolder.exists()) {
iFolder.create(true, true, new NullProgressMonitor());
}
IFile subjobXmlFile = iProject.getFile(subjobPath);
subJobContainerArray = converterUtil.convertToUiXml(importFromPath.toFile(), subJobFile, parameterFile,true);
if (!subjobXmlFile.exists() && subJobContainerArray[1] == null) {
subjobXmlFile.create(new FileInputStream(importFromPath.toString()), true, new NullProgressMonitor());
}
}
return (Container) subJobContainerArray[0];
}
示例12: chooseWorkspace
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
protected void chooseWorkspace ()
{
final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog ( getShell (), new WorkbenchLabelProvider (), new WorkbenchContentProvider () );
dialog.setTitle ( "Select driver exporter configuration file" );
dialog.setMessage ( "Choose a driver exporter file for the configuration" );
dialog.setInput ( ResourcesPlugin.getWorkspace ().getRoot () );
dialog.setComparator ( new ResourceComparator ( ResourceComparator.NAME ) );
dialog.setAllowMultiple ( true );
dialog.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.WORKSPACE_SELECTION_DIALOG ), Dialog.DIALOG_PERSISTSIZE );
if ( dialog.open () == IDialogConstants.OK_ID )
{
final IResource resource = (IResource)dialog.getFirstResult ();
if ( resource != null )
{
final String arg = resource.getFullPath ().toString ();
final String fileLoc = VariablesPlugin.getDefault ().getStringVariableManager ().generateVariableExpression ( "workspace_loc", arg ); //$NON-NLS-1$
this.fileText.setText ( fileLoc );
makeDirty ();
}
}
}
示例13: getTemplates
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
*
* @param modelingProject the name of the selected modeling project
* @return the list of all the report templates name that are available in the selected modeling project
*/
public static List<String> getTemplates(String modelingProject) { // For the SimulationManagementWindow (names)
List<String> templatesName = new ArrayList<String>();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(modelingProject);
IFolder templatesFolder = project.getFolder("Report Templates");
try {
IResource[] folderContent = templatesFolder.members();
for(IResource resource : folderContent) {
if(resource.getType() == IFile.FILE && resource.getFileExtension().equals("rptdesign")) {
templatesName.add(resource.getName());
}
}
} catch (CoreException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Error: " + e.getMessage() + "", "Error", JOptionPane.ERROR_MESSAGE);
}
return templatesName;
}
示例14: showInstruction
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
/**
* Show the given {@link EObject instruction}.
*
* @param editorPart
* the opened {@link DialectEditor}
* @param instruction
* the {@link EObject instruction} to show
*/
public static void showInstruction(DialectEditor editorPart, EObject instruction) {
final URI resourceURI = instruction.eResource().getURI();
if (resourceURI.isPlatformResource()) {
final String resourcePath = resourceURI.toPlatformString(true);
final IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
resourcePath));
try {
final IMarker marker = resource.createMarker(EValidator.MARKER);
marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
final TraceabilityMarkerNavigationProvider navigationProvider = new TraceabilityMarkerNavigationProvider(
(DialectEditor)editorPart);
navigationProvider.gotoMarker(marker);
marker.delete();
} catch (CoreException e) {
DebugSiriusIdeUiPlugin.INSTANCE.log(e);
}
}
}
示例15: performFinish
import org.eclipse.core.resources.ResourcesPlugin; //導入依賴的package包/類
public boolean performFinish() {
final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();
WorkspaceJob job = new WorkspaceJob("Unzipping Projects") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Unzipping Projects", projectDescriptors.size());
//System.out.println("Unzipping projects...");
for ( ProjectDescriptor desc : projectDescriptors ) {
unzipProject(desc, monitor);
monitor.worked(1);
}
//System.out.println("Projects unzipped");
return Status.OK_STATUS;
}
};
job.setRule(ResourcesPlugin.getWorkspace().getRoot());
job.schedule();
return true;
}