本文整理汇总了Java中org.eclipse.core.resources.IContainer类的典型用法代码示例。如果您正苦于以下问题:Java IContainer类的具体用法?Java IContainer怎么用?Java IContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IContainer类属于org.eclipse.core.resources包,在下文中一共展示了IContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resfreshFileInContainer
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* @param folder
* @param filetorefresh
* @return
* @throws CoreException
* @throws InterruptedException
*/
public static IResource resfreshFileInContainer(IContainer folder, String filetorefresh)
throws CoreException, InterruptedException {
final IResource buildfile = find(folder, filetorefresh);
Job job = new WorkspaceJob("Refresh folders") {
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
if (buildfile != null && buildfile.exists()) {
try {
buildfile.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException e) {
ResourceManager.logException(e);
}
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return buildfile;
}
示例2: ModuleSpecifierSelectionDialog
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* Create the dialog.
*
* <p>
* Note: The model should have a valid source folder path as this is the root folder for this browse dialog. If the
* source folder path doesn't exist yet this dialog will be empty.
* </p>
*
* @param parent
* Parent Shell
* @param sourceFolder
* The source folder to browse in for modules and module folders
*
*
*/
public ModuleSpecifierSelectionDialog(Shell parent, IPath sourceFolder) {
super(parent, MODULE_ELEMENT_NAME, CREATE_FOLDER_LABEL);
this.setTitle("Select a module");
this.setInputValidator(inputValidator);
IPath parentPath = sourceFolder.removeLastSegments(1);
IContainer sourceFolderParent = containerForPath(parentPath);
IFolder workspaceSourceFolder = workspaceRoot
.getFolder(sourceFolder);
// Use parent of source folder as root to show source folder itself in the tree
this.treeRoot = sourceFolderParent;
this.sourceFolder = workspaceSourceFolder;
this.addFilter(new ModuleFolderFilter(this.sourceFolder.getFullPath()));
this.setAutoExpandLevel(2);
// Show the status line above the buttons
this.setStatusLineAboveButtons(true);
}
示例3: mkdirs
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
private static void mkdirs(IFolder destPath) {
IContainer parent = destPath.getParent();
if (! parent.exists()) {
if (parent instanceof IFolder) {
mkdirs((IFolder) parent);
}
else if (parent instanceof IProject) {
mkdirs( ((IProject)parent).getFolder(".") );
}
}
try {
destPath.create(/*force*/true, /*local*/true, Constants.NULL_PROGRESS_MONITOR);
} catch (CoreException e) {
e.printStackTrace();
}
}
示例4: cleanOutput
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
private void cleanOutput(IProject aProject, OutputConfiguration config, IProgressMonitor monitor)
throws CoreException {
IContainer container = getContainer(aProject, config.getOutputDirectory());
if (!container.exists()) {
return;
}
if (config.isCanClearOutputDirectory()) {
for (IResource resource : container.members()) {
resource.delete(IResource.KEEP_HISTORY, monitor);
}
} else if (config.isCleanUpDerivedResources()) {
List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
for (IFile iFile : resources) {
iFile.delete(IResource.KEEP_HISTORY, monitor);
}
}
}
示例5: getGeneratorMarkers
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
@Override
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject,
Collection<OutputConfiguration> outputConfigurations) throws CoreException {
if (builtProject instanceof ExternalProject) {
return emptyMap();
}
Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
for (OutputConfiguration config : outputConfigurations) {
if (config.isCleanUpDerivedResources()) {
List<IMarker> markers = Lists.newArrayList();
for (IContainer container : getOutputs(builtProject, config)) {
Iterables.addAll(
markers,
getDerivedResourceMarkers().findDerivedResourceMarkers(container,
getGeneratorIdProvider().getGeneratorIdentifier()));
}
generatorMarkers.put(config, markers);
}
}
return generatorMarkers;
}
示例6: toLaunchConfiguration
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* Converts a {@link TestConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in
* case of error.
*
* @see TestConfiguration#readPersistentValues()
*/
public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, TestConfiguration testConfig) {
try {
final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager()
.getLaunchConfigurations(type);
for (ILaunchConfiguration config : configs) {
if (equals(testConfig, config))
return config;
}
final IContainer container = null;
final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, testConfig.getName());
workingCopy.setAttributes(testConfig.readPersistentValues());
return workingCopy.doSave();
} catch (Exception e) {
throw new WrappedException("could not convert N4JS TestConfiguration to Eclipse ILaunchConfiguration", e);
}
}
示例7: toLaunchConfiguration
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* Converts a {@link RunConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in
* case of error.
*
* @see RunConfiguration#readPersistentValues()
*/
public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, RunConfiguration runConfig) {
try {
final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager()
.getLaunchConfigurations(type);
for (ILaunchConfiguration config : configs) {
if (equals(runConfig, config))
return config;
}
final IContainer container = null;
final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, runConfig.getName());
workingCopy.setAttributes(runConfig.readPersistentValues());
return workingCopy.doSave();
} catch (Exception e) {
throw new WrappedException("could not convert N4JS RunConfiguration to Eclipse ILaunchConfiguration", e);
}
}
示例8: openContentStream
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* Returns the content of the .editorconfig file to generate.
*
* @param container
*
* @return the content of the .editorconfig file to generate.
*/
private InputStream openContentStream(IContainer container) {
IPreferenceStore store = EditorsUI.getPreferenceStore();
boolean spacesForTabs = store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
int tabWidth = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
String lineDelimiter = getLineDelimiter(container);
String endOfLine = org.ec4j.core.model.PropertyType.EndOfLineValue.ofEndOfLineString(lineDelimiter).name();
StringBuilder content = new StringBuilder("# EditorConfig is awesome: http://EditorConfig.org");
content.append(lineDelimiter);
content.append(lineDelimiter);
content.append("[*]");
content.append(lineDelimiter);
content.append("indent_style = ");
content.append(spacesForTabs ? "space" : "tab");
content.append(lineDelimiter);
content.append("indent_size = ");
content.append(tabWidth);
if (endOfLine != null) {
content.append(lineDelimiter);
content.append("end_of_line = ");
content.append(endOfLine);
}
return new ByteArrayInputStream(content.toString().getBytes());
}
示例9: addJvmOptions
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
private void addJvmOptions ( final ILaunchConfigurationWorkingCopy cfg, final Profile profile, final IContainer container ) throws CoreException
{
final List<String> args = new LinkedList<> ();
args.addAll ( profile.getJvmArguments () );
for ( final SystemProperty p : profile.getProperty () )
{
addSystemProperty ( profile, args, p.getKey (), p.getValue (), p.isEval () );
}
for ( final Map.Entry<String, String> entry : getInitialProperties ().entrySet () )
{
addSystemProperty ( profile, args, entry.getKey (), entry.getValue (), false );
}
final IFile dataJson = container.getFile ( new Path ( "data.json" ) ); //$NON-NLS-1$
if ( dataJson.exists () )
{
addJvmArg ( args, "org.eclipse.scada.ca.file.provisionJsonUrl", escapeArgValue ( dataJson.getLocation ().toFile ().toURI ().toString () ) ); //$NON-NLS-1$
}
cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, StringHelper.join ( args, "\n" ) );
cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, StringHelper.join ( profile.getArguments (), "\n" ) );
}
示例10: processFile
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
public static void processFile ( final IContainer parent, final Definition definition, final Profile profile, final IProgressMonitor monitor ) throws Exception
{
monitor.beginTask ( makeJobLabel ( definition, profile ), 100 );
final IFolder output = parent.getFolder ( new Path ( "output" ) ); //$NON-NLS-1$
if ( output.exists () )
{
output.delete ( true, new SubProgressMonitor ( monitor, 9 ) );
}
output.create ( true, true, new SubProgressMonitor ( monitor, 1 ) );
final Builder builder = new Builder ( definition, profile );
final Recipe recipe = builder.build ();
try
{
final Map<String, Object> initialContent = new HashMap<String, Object> ();
initialContent.put ( "output", output ); //$NON-NLS-1$
recipe.execute ( initialContent, new SubProgressMonitor ( monitor, 90 ) );
}
finally
{
monitor.done ();
}
}
示例11: getGraphModels
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* Retrieve the graph models contained in the container
*
* @param container
* @param models
* @throws CoreException
*/
public static void getGraphModels(IContainer container, List<IFile> models) throws CoreException {
if (!container.exists())
return;
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer)
getGraphModels((IContainer) member, models);
else if (member instanceof IFile) {
IFile file = (IFile) member;
if (PreferenceManager.isGraphModelFile(file))
models.add(file);
if (PreferenceManager.isGW3ModelFile(file))
models.add(file);
if (PreferenceManager.isJSONModelFile(file))
models.add(file);
}
}
}
示例12: createFileDeleteIfExists
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* Create a file in a folder with the specified name and content
*
* @param fullpath
* @param filename
* @param content
* @throws CoreException
* @throws InterruptedException
*/
public static IFile createFileDeleteIfExists(String fullpath, String filename, String content,
IProgressMonitor monitor) throws CoreException, InterruptedException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
subMonitor.setTaskName("Create file delete if it exists " + fullpath);
IFile newFile;
try {
IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
IContainer container = (IContainer) wroot.findMember(new Path(fullpath));
newFile = container.getFile(new Path(filename));
if (newFile.exists()) {
JDTManager.rename(newFile, new NullProgressMonitor());
newFile.delete(true, new NullProgressMonitor());
}
subMonitor.split(30);
byte[] source = content.getBytes(Charset.forName("UTF-8"));
newFile.create(new ByteArrayInputStream(source), true, new NullProgressMonitor());
subMonitor.split(70);
} finally {
subMonitor.done();
}
return newFile;
}
示例13: processContainer
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* @param container
* @param path
* @return
* @throws CoreException
*/
private static IFile processContainer(IContainer container, String path) throws CoreException {
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer) {
IFile file = processContainer((IContainer) member, path);
if (file != null) {
IPath p = ResourceManager.getPathWithinPackageFragment(file); // avoid
// file
// within
// classes
// directory
if (p != null)
return file;
}
} else if (member instanceof IFile) {
IFile ifile = (IFile) member;
if (ifile.getFullPath().toString().endsWith(path)) {
return ifile;
}
}
}
return null;
}
示例14: getAllJUnitResultFiles
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* @param container
* @param files
* @throws CoreException
*/
public static void getAllJUnitResultFiles(String projectName, List<IFile> files) throws CoreException {
if (projectName == null)
return;
IContainer container = ResourceManager.getProject(projectName);
container.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IFile) {
IFile file = (IFile) member;
if (isJUnitResultFile(file)) {
files.add(file);
}
}
}
}
示例15: resourceExistsIn
import org.eclipse.core.resources.IContainer; //导入依赖的package包/类
/**
* Process recursively the containers until we found a resource with the
* specified path
*
* @param container
* @param path
* @return
* @throws CoreException
*/
private static boolean resourceExistsIn(IContainer container, IPath path) throws CoreException {
boolean found = false;
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer) {
found = resourceExistsIn((IContainer) member, path);
if (found)
break;
} else if (member instanceof IFile) {
IFile file = (IFile) member;
if (path.equals(file.getFullPath()))
return true;
}
}
return found;
}