当前位置: 首页>>代码示例>>Java>>正文


Java IResource.getType方法代码示例

本文整理汇总了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);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:29,代码来源:TargetHandlerDialog.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:JPFManifestBuilder.java

示例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;
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:28,代码来源:ResourceStore.java

示例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);
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:10,代码来源:PgUIDumpLoader.java

示例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);
	}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:31,代码来源:GraphModelPropertyPage.java

示例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);
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:54,代码来源:IntDeploymentMainPage.java

示例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);
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:54,代码来源:ServicesMainPage.java

示例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);
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:54,代码来源:FinalAssemblyMainPage.java

示例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;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:75,代码来源:JavaHotCodeReplaceProvider.java

示例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);
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:55,代码来源:InfrastructureModelWizard.java

示例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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:61,代码来源:ProtocolModelWizard.java

示例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) {
			
		}
	}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:48,代码来源:ProjectTreeObject.java

示例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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:47,代码来源:NewArchiveWizardPage.java

示例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);
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:54,代码来源:InitAssemblyMainPage.java

示例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);
			}
		}
	}
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:45,代码来源:NewDiagramWizard.java


注:本文中的org.eclipse.core.resources.IResource.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。