本文整理汇总了Java中org.eclipse.core.resources.IResource.getType方法的典型用法代码示例。如果您正苦于以下问题:Java IResource.getType方法的具体用法?Java IResource.getType怎么用?Java IResource.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IResource
的用法示例。
在下文中一共展示了IResource.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dialogChanged
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Ensures that both text fields are set.
*/
private void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot()
.findMember(new Path(getContainerName().get("ProjectPath")));
if(!containerSourceText.getText().isEmpty() && !containerTargetText.getText().isEmpty())
{
okButton.setEnabled(true);
}
if (getContainerName().get("ProjectPath").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);
}
示例2: visit
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public boolean visit(IResourceDelta delta) throws CoreException
{
IResource resource = delta.getResource();
if( resource.isDerived() )
{
return false;
}
if( resource.getType() == IResource.FILE )
{
IFile file = (IFile) resource;
IProject project = resource.getProject();
if( file.equals(JPFProject.getManifest(project)) )
{
manifestChanged = true;
return false;
}
}
return true;
}
示例3: visit
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public boolean visit(IResource resource) throws CoreException {
if (ResourceUtils.isTargetFolder(resource)) {
/* Dossier target : on n'explore pas. */
return false;
}
if (resource.getType() != IResource.FILE) {
/* Dossier : on continue la visite. */
return true;
}
/* La ressource est un fichier. */
IFile file = (IFile) resource;
/* Vérification que le fichier est candidat. */
if (!implementor.isCandidate(file)) {
return false;
}
/* Traitement du fichier. */
FileProvider fileProvider = new FileProvider(file, project, javaProject, DOCUMENT_PROVIDER);
handleFile(fileProvider);
return false;
}
示例4: loadSubdir
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
private static void loadSubdir(IFolder folder, PgDatabase db, IProgressMonitor monitor,
List<FunctionBodyContainer> funcBodies, Map<String, List<AntlrError>> errors)
throws InterruptedException, IOException, CoreException {
for (IResource resource : folder.members()) {
if (resource.getType() == IResource.FILE && "sql".equals(resource.getFileExtension())) { //$NON-NLS-1$
loadFile((IFile) resource, monitor, db, funcBodies, errors);
}
}
}
示例5: createContents
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public Control createContents(Composite parent) {
noDefaultAndApplyButton();
Composite panel = createComposite(parent, 2);
// PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),PROPERTY_PAGE_CONTEXT);
IResource resource = (IResource) getElement();
if (resource.getType() == IResource.FILE) {
Label label = createLabel(panel, MessageUtil.getString("File_name")); //$NON-NLS-1$
label = createLabel(panel, resource.getName());
label.setData(GW4E_LABEL_ID,GW4E_LABEL_ID);
fillExcessHorizontalSpace(label);
//
createLabel(panel, MessageUtil.getString("Path")); //$NON-NLS-1$
label = createLabel(panel, resource.getFullPath().setDevice(null).toString());
fillExcessHorizontalSpace(label);
createLabel(panel, MessageUtil.getString("modified")); //$NON-NLS-1$
IFile file = (IFile) resource;
label = createLabel(panel, formatDate(new Date(file.getLocalTimeStamp())));
fillExcessHorizontalSpace(label);
createrequirementSection(panel, file);
createMethodSection(panel, file);
}
return new Canvas(panel, 0);
}
示例6: dialogChanged
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Ensures that both text fields are set.
*/
private void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName()));
String fileName = getFileName();
if (getContainerName().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;
}
if (fileName.length() == 0) {
updateStatus("File name must be specified");
return;
}
if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
updateStatus("File name must be valid");
return;
}
File file = new File(container.getLocation().toOSString());
File[] contains = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.getName().equalsIgnoreCase(fileName))
return true;
else
return false;
}
});
if (contains != null && contains.length > 0) {
updateStatus("File name must be different");
return;
}
int dotLoc = fileName.lastIndexOf('.');
if (dotLoc != -1) {
String ext = fileName.substring(dotLoc + 1);
if (ext.equalsIgnoreCase("deploy") == false) {
updateStatus("File extension must be \"deploy\"");
return;
}
}
updateStatus(null);
}
示例7: dialogChanged
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Ensures that both text fields are set.
*/
private void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName()));
String fileName = getFileName();
if (getContainerName().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;
}
if (fileName.length() == 0) {
updateStatus("File name must be specified");
return;
}
if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
updateStatus("File name must be valid");
return;
}
File file = new File(container.getLocation().toOSString());
File[] contains = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.getName().equalsIgnoreCase(fileName))
return true;
else
return false;
}
});
if (contains != null && contains.length > 0) {
updateStatus("File name must be different");
return;
}
int dotLoc = fileName.lastIndexOf('.');
if (dotLoc != -1) {
String ext = fileName.substring(dotLoc + 1);
if (ext.equalsIgnoreCase("srvc") == false) {
updateStatus("File extension must be \"srvc\"");
return;
}
}
updateStatus(null);
}
示例8: dialogChanged
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Ensures that both text fields are set.
*/
private void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName()));
String fileName = getFileName();
if (getContainerName().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;
}
if (fileName.length() == 0) {
updateStatus("File name must be specified");
return;
}
if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
updateStatus("File name must be valid");
return;
}
File file = new File(container.getLocation().toOSString());
File[] contains = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.getName().equalsIgnoreCase(fileName))
return true;
else
return false;
}
});
if (contains != null && contains.length > 0) {
updateStatus("File name must be different");
return;
}
int dotLoc = fileName.lastIndexOf('.');
if (dotLoc != -1) {
String ext = fileName.substring(dotLoc + 1);
if (ext.equalsIgnoreCase("fassmbl") == false) {
updateStatus("File extension must be \"fassmbl\"");
return;
}
}
updateStatus(null);
}
示例9: visit
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Answers whether children should be visited.
* <p>
* If the associated resource is a class file which has been changed, record it.
* </p>
*/
@Override
public boolean visit(IResourceDelta delta) {
if (delta == null || 0 == (delta.getKind() & IResourceDelta.CHANGED)) {
return false;
}
IResource resource = delta.getResource();
if (resource != null) {
switch (resource.getType()) {
case IResource.FILE:
if (0 == (delta.getFlags() & IResourceDelta.CONTENT)) {
return false;
}
if (CLASS_FILE_EXTENSION.equals(resource.getFullPath().getFileExtension())) {
IPath localLocation = resource.getLocation();
if (localLocation != null) {
String path = localLocation.toOSString();
IClassFileReader reader = ToolFactory.createDefaultClassFileReader(path,
IClassFileReader.CLASSFILE_ATTRIBUTES);
if (reader != null) {
// this name is slash-delimited
String qualifiedName = new String(reader.getClassName());
boolean hasBlockingErrors = false;
try {
// If the user doesn't want to replace
// classfiles containing
// compilation errors, get the source
// file associated with
// the class file and query it for
// compilation errors
IJavaProject pro = JavaCore.create(resource.getProject());
ISourceAttribute sourceAttribute = reader.getSourceFileAttribute();
String sourceName = null;
if (sourceAttribute != null) {
sourceName = new String(sourceAttribute.getSourceFileName());
}
IResource sourceFile = getSourceFile(pro, qualifiedName, sourceName);
if (sourceFile != null) {
IMarker[] problemMarkers = null;
problemMarkers = sourceFile.findMarkers(
IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
IResource.DEPTH_INFINITE);
for (IMarker problemMarker : problemMarkers) {
if (problemMarker.getAttribute(IMarker.SEVERITY,
-1) == IMarker.SEVERITY_ERROR) {
hasBlockingErrors = true;
break;
}
}
}
} catch (CoreException e) {
logger.log(Level.SEVERE, "Failed to visit classes: " + e.getMessage(), e);
}
if (!hasBlockingErrors) {
changedFiles.add(resource);
// dot-delimit the name
fullyQualifiedNames.add(qualifiedName.replace('/', '.'));
}
}
}
}
return false;
default:
return true;
}
}
return true;
}
示例10: addPages
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* The framework calls this to create the contents of the wizard.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void addPages() {
// Create a page, set the title, and the initial model file name.
//
newFileCreationPage = new InfrastructureModelWizardNewFileCreationPage("Whatever", selection);
newFileCreationPage.setTitle(InfrastructureEditorPlugin.INSTANCE.getString("_UI_InfrastructureModelWizard_label"));
newFileCreationPage.setDescription(InfrastructureEditorPlugin.INSTANCE.getString("_UI_InfrastructureModelWizard_description"));
newFileCreationPage.setFileName(InfrastructureEditorPlugin.INSTANCE.getString("_UI_InfrastructureEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
addPage(newFileCreationPage);
// Try and get the resource selection to determine a current directory for the file dialog.
//
if (selection != null && !selection.isEmpty()) {
// Get the resource...
//
Object selectedElement = selection.iterator().next();
if (selectedElement instanceof IResource) {
// Get the resource parent, if its a file.
//
IResource selectedResource = (IResource)selectedElement;
if (selectedResource.getType() == IResource.FILE) {
selectedResource = selectedResource.getParent();
}
// This gives us a directory...
//
if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
// Set this for the container.
//
newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
// Make up a unique new name here.
//
String defaultModelBaseFilename = InfrastructureEditorPlugin.INSTANCE.getString("_UI_InfrastructureEditorFilenameDefaultBase");
String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
}
newFileCreationPage.setFileName(modelFilename);
}
}
}
initialObjectCreationPage = new InfrastructureModelWizardInitialObjectCreationPage("Whatever2");
initialObjectCreationPage.setTitle(InfrastructureEditorPlugin.INSTANCE.getString("_UI_InfrastructureModelWizard_label"));
initialObjectCreationPage.setDescription(InfrastructureEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
addPage(initialObjectCreationPage);
}
示例11: addPages
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* The framework calls this to create the contents of the wizard.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void addPages ()
{
// Create a page, set the title, and the initial model file name.
//
newFileCreationPage = new ProtocolModelWizardNewFileCreationPage ( "Whatever", selection ); //$NON-NLS-1$
newFileCreationPage.setTitle ( NextGenerationProtocolEditorPlugin.INSTANCE.getString ( "_UI_ProtocolModelWizard_label" ) ); //$NON-NLS-1$
newFileCreationPage.setDescription ( NextGenerationProtocolEditorPlugin.INSTANCE.getString ( "_UI_ProtocolModelWizard_description" ) ); //$NON-NLS-1$
newFileCreationPage.setFileName ( NextGenerationProtocolEditorPlugin.INSTANCE.getString ( "_UI_ProtocolEditorFilenameDefaultBase" ) + "." + FILE_EXTENSIONS.get ( 0 ) ); //$NON-NLS-1$ //$NON-NLS-2$
addPage ( newFileCreationPage );
// Try and get the resource selection to determine a current directory for the file dialog.
//
if ( selection != null && !selection.isEmpty () )
{
// Get the resource...
//
Object selectedElement = selection.iterator ().next ();
if ( selectedElement instanceof IResource )
{
// Get the resource parent, if its a file.
//
IResource selectedResource = (IResource)selectedElement;
if ( selectedResource.getType () == IResource.FILE )
{
selectedResource = selectedResource.getParent ();
}
// This gives us a directory...
//
if ( selectedResource instanceof IFolder || selectedResource instanceof IProject )
{
// Set this for the container.
//
newFileCreationPage.setContainerFullPath ( selectedResource.getFullPath () );
// Make up a unique new name here.
//
String defaultModelBaseFilename = NextGenerationProtocolEditorPlugin.INSTANCE.getString ( "_UI_ProtocolEditorFilenameDefaultBase" ); //$NON-NLS-1$
String defaultModelFilenameExtension = FILE_EXTENSIONS.get ( 0 );
String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; //$NON-NLS-1$
for ( int i = 1; ( (IContainer)selectedResource ).findMember ( modelFilename ) != null; ++i )
{
modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; //$NON-NLS-1$
}
newFileCreationPage.setFileName ( modelFilename );
}
}
}
initialObjectCreationPage = new ProtocolModelWizardInitialObjectCreationPage ( "Whatever2" ); //$NON-NLS-1$
initialObjectCreationPage.setTitle ( NextGenerationProtocolEditorPlugin.INSTANCE.getString ( "_UI_ProtocolModelWizard_label" ) ); //$NON-NLS-1$
initialObjectCreationPage.setDescription ( NextGenerationProtocolEditorPlugin.INSTANCE.getString ( "_UI_Wizard_initial_object_description" ) ); //$NON-NLS-1$
addPage ( initialObjectCreationPage );
}
示例12: resourceChanged
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public void resourceChanged(IResourceChangeEvent event) {
//we are only interested in POST_CHANGE events
if (event.getType() != IResourceChangeEvent.POST_CHANGE) {
return;
}
// final ProjectTreeObject projectTreeObject = this;
final String projectName = getName();
IPath path = new Path(projectName);
IResourceDelta projectDelta = event.getDelta().findMember(path);
if (projectDelta == null) {
return;
}
IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) {
//only interested in changed resources (not added or removed)
if (delta.getKind() != IResourceDelta.CHANGED) {
return true;
}
//only interested in content changes
if ((delta.getFlags() & IResourceDelta.CONTENT) == 0) {
return true;
}
IResource resource = delta.getResource();
//only interested in files
if (resource.getType() == IResource.FILE) {
if ("xsd".equalsIgnoreCase(resource.getFileExtension())) {
// Project project = getObject();
// project.setXsdDirty(true);
// TreeObjectEvent treeObjectEvent1 = new TreeObjectEvent(projectTreeObject, "schemaType", null, null, 0);
// ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent1);
// TreeObjectEvent treeObjectEvent2 = new TreeObjectEvent(projectTreeObject, "xsdFile", null, null, 0);
// ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent2);
}
}
return true;
}
};
try {
projectDelta.accept(visitor);
} catch (CoreException e) {
}
}
示例13: dialogChanged
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Ensures that both text fields are set.
*/
private void dialogChanged ()
{
final IResource container = ResourcesPlugin.getWorkspace ().getRoot ().findMember ( new Path ( getContainerName () ) );
final String fileName = getFileName ();
if ( getContainerName ().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;
}
if ( fileName.length () == 0 )
{
updateStatus ( "File name must be specified" );
return;
}
if ( fileName.replace ( '\\', '/' ).indexOf ( '/', 1 ) > 0 )
{
updateStatus ( "File name must be valid" );
return;
}
final int dotLoc = fileName.lastIndexOf ( '.' );
if ( dotLoc != -1 )
{
final String ext = fileName.substring ( dotLoc + 1 );
if ( ext.equalsIgnoreCase ( "oscar" ) == false )
{
updateStatus ( "File extension must be \"oscar\"" );
return;
}
}
updateStatus ( null );
}
示例14: dialogChanged
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* Ensures that both text fields are set.
*/
private void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName()));
String fileName = getFileName();
if (getContainerName().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;
}
if (fileName.length() == 0) {
updateStatus("File name must be specified");
return;
}
if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
updateStatus("File name must be valid");
return;
}
File file = new File(container.getLocation().toOSString());
File[] contains = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.getName().equalsIgnoreCase(fileName))
return true;
else
return false;
}
});
if (contains != null && contains.length > 0) {
updateStatus("File name must be different");
return;
}
int dotLoc = fileName.lastIndexOf('.');
if (dotLoc != -1) {
String ext = fileName.substring(dotLoc + 1);
if (ext.equalsIgnoreCase("assmbl") == false) {
updateStatus("File extension must be \"assmbl\"");
return;
}
}
updateStatus(null);
}
示例15: addPages
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* The framework calls this to create the contents of the wizard.
*/
@Override
public void addPages() {
newFileCreationPage = createNewFilePage();
newFileCreationPage.setTitle(Messages.NewConfigurationWizard_PageTitle);
newFileCreationPage.setDescription(Messages.NewConfigurationWizard_PageDescription);
newFileCreationPage.setFileName(Messages.NewConfigurationWizard_DefaultModelName + "." + fileExt); // $NON-NLS-2$
addPage(newFileCreationPage);
// Try and get the resource selection to determine a current directory
// for the file dialog.
//
if (selection != null && !selection.isEmpty()) {
// Get the resource...
//
Object selectedElement = selection.iterator().next();
if (selectedElement instanceof IResource) {
// Get the resource parent, if its a file.
//
IResource selectedResource = (IResource) selectedElement;
if (selectedResource.getType() == IResource.FILE) {
selectedResource = selectedResource.getParent();
}
// This gives us a directory...
//
if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
// Set this for the container.
//
newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
// Make up a unique new name here.
//
String defaultModelBaseFilename = Messages.NewConfigurationWizard_DefaultModelName;
String modelFilename = defaultModelBaseFilename + "." + fileExt; //$NON-NLS-1$
for (int i = 1; ((IContainer) selectedResource).findMember(modelFilename) != null; ++i) {
modelFilename = defaultModelBaseFilename + i + "." + fileExt; //$NON-NLS-1$
}
newFileCreationPage.setFileName(modelFilename);
}
}
}
}