當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。