本文整理了Java中org.netbeans.spi.project.ui.templates.support.Templates
类的一些代码示例,展示了Templates
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Templates
类的具体详情如下:
包路径:org.netbeans.spi.project.ui.templates.support.Templates
类名称:Templates
暂无
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-clientproject
@Override
public Set<FileObject> instantiate() throws IOException {
FileObject dir = Templates.getTargetFolder(descriptor);
FileObject template = Templates.getTemplate(descriptor);
DataFolder dataFolder = DataFolder.findFolder(dir);
DataObject dataTemplate = DataObject.find(template);
DataObject createdFile = dataTemplate.createFromTemplate(dataFolder, Templates.getTargetName(descriptor));
return Collections.singleton(createdFile.getPrimaryFile());
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
@Override
public Set<DataObject> instantiate(TemplateWizard wizard) throws IOException {
Project project = Templates.getProject( wizard );
String targetName = Templates.getTargetName(wizard);
FileObject targetDir = Templates.getTargetFolder(wizard);
FileObject fo = createFacesConfig(project, targetDir, targetName, true);
if (fo != null) {
return Collections.singleton(DataObject.find(fo));
} else {
return Collections.EMPTY_SET;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans
public void initialize(WizardDescriptor wizard) {
this.wizard = wizard;
if (Templates.getTargetFolder(wizard) == null) {
Project project = Templates.getProject(wizard);
SpringConfigFileLocationProvider provider = project != null ? project.getLookup().lookup(SpringConfigFileLocationProvider.class) : null;
FileObject location = provider != null ? provider.getLocation() : null;
if (location != null) {
Templates.setTargetFolder(wizard, location);
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-clientproject
private WizardDescriptor.Panel<WizardDescriptor>[] getPanels() {
Project project = Templates.getProject(descriptor);
SourceGroup[] groups = getSourceGroups(project, Templates.getTemplate(descriptor));
WizardDescriptor.Panel<WizardDescriptor> simpleTargetChooserPanel = Templates.buildSimpleTargetChooser(project, groups).create();
@SuppressWarnings({"unchecked", "rawtypes"})
WizardDescriptor.Panel<WizardDescriptor>[] panels = new WizardDescriptor.Panel[] {simpleTargetChooserPanel};
return panels;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
@Override
public Set<DataObject> instantiate(TemplateWizard wiz) throws IOException {
DataObject result = null;
String targetName = Templates.getTargetName(wizard);
FileObject targetDir = Templates.getTargetFolder(wizard);
DataFolder df = DataFolder.findFolder(targetDir);
FileObject template = Templates.getTemplate( wizard );
DataObject dTemplate = DataObject.find(template);
HashMap<String, Object> templateProperties = new HashMap<String, Object>();
if (selectedText != null) {
templateProperties.put("implementation", selectedText); //NOI18N
}
Project project = Templates.getProject(wizard);
WebModule webModule = WebModule.getWebModule(project.getProjectDirectory());
if (webModule != null) {
JSFVersion version = JSFVersion.forWebModule(webModule);
if (version != null && version.isAtLeast(JSFVersion.JSF_2_2)) {
templateProperties.put("isJSF22", Boolean.TRUE); //NOI18N
}
}
result = dTemplate.createFromTemplate(df,targetName,templateProperties);
return Collections.singleton(result);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project
@Override
public void readSettings(WizardDescriptor settings) {
this.settings = settings;
FileObject preselectedFolder = Templates.getTargetFolder(settings);
component.initValues(Templates.getTemplate(settings), preselectedFolder);
// XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
// this name is used in NewFileWizard to modify the title
Object substitute = component.getClientProperty("NewFileWizard_Title"); // NOI18N
if (substitute != null) {
settings.putProperty("NewFileWizard_Title", substitute); // NOI18N
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
public CompositeComponentWizardPanel(TemplateWizard wizard, SourceGroup[] folders, String selectedText) {
this.wizard = wizard;
text = selectedText;
this.folders = folders;
project = Templates.getProject(wizard);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
@Override
public void initialize(TemplateWizard wizard) {
Project project = Templates.getProject( wizard );
Sources sources = ProjectUtils.getSources(project);
SourceGroup[] sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_WEB_INF);
folderPanel = new FacesConfigValidationPanel(Templates.buildSimpleTargetChooser(project, sourceGroups).create());
panels = new WizardDescriptor.Panel[] { folderPanel };
FileObject targetFolder = Templates.getTargetFolder(wizard);
String relativePath = (targetFolder == null) ? null : FileUtil.getRelativePath(webInf, targetFolder);
if (relativePath == null) {
Templates.setTargetFolder(wizard, webInf);
Templates.setTargetName(wizard, defaultName);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf
public void initialize(TemplateWizard wizard) {
index = 0;
Project project = Templates.getProject(wizard);
SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
String templateType = Templates.getTemplate(wizard).getExt();
FileObject jspDir = Templates.getTargetFolder(wizard);
String relativePath = (jspDir == null) ? null : FileUtil.getRelativePath(docRoot, jspDir);
if ((relativePath == null) || (relativePath.indexOf("WEB-INF") != -1)) {
Templates.setTargetFolder(wizard, docRoot);
jspDir = docRoot;
} else if (relativePath.length() > 0) {
String ext = Templates.getTemplate(wizard).getExt();
String prefix = "jsp".equals(ext) ? "Page" : "Fragment"; // NOI18N
for (int pageIndex = 1;; pageIndex++) {
FileObject beanDir = Templates.getTargetFolder(wizard);
String relativePath = (beanDir == null) ? null : FileUtil.getRelativePath(javaDir, beanDir);
if (relativePath == null) {
Templates.setTargetFolder(wizard, javaDir);
beanDir = javaDir;
String header = Templates.getTemplate(wizard).getName();
for (int beanIndex = 1;; beanIndex++) {
String name = header + beanIndex;
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-support
/**
* Return template that should be used for file creation. By default it uses
* {@link Templates#getTemplate(org.openide.WizardDescriptor)} method, but it
* is possible to override this behavior in subclasses.
*
* @return file template
*/
protected FileObject findCorrectTemplate() {
return Templates.getTemplate(wiz);
}
代码示例来源:origin: AlexFalappa/nb-springboot
@Override
public Set<?> instantiate() throws IOException {
final Project project = Templates.getProject(wizard);
if (project == null) {
return null;
Templates.setTargetFolder(wizard, foDir);
Templates.setTargetName(wizard, targetName);
File fExisting = new File(fDir, targetName);
if (fExisting.exists()) {
FileObject foTemplate = Templates.getTemplate(wizard);
DataObject doTemplate = DataObject.find(foTemplate);
DataFolder df = DataFolder.findFolder(foDir);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-selenium2-php
@Override
public WizardDescriptor.Panel createTargetChooserPanel(WizardDescriptor wiz) {
Project project = Templates.getProject(wiz);
SourceGroup seleniumSourceGroup = getSeleniumSourceGroup(project);
return Templates.buildSimpleTargetChooser(project, new SourceGroup[]{seleniumSourceGroup}).create();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-junit-ui
@Override
public Set<DataObject> instantiate() throws IOException {
saveSettings(wizard);
/* collect and build necessary data: */
String name = Templates.getTargetName(wizard);
FileObject targetFolder = Templates.getTargetFolder(wizard);
FileObject testRootFolder = findTestRootFolder(targetFolder);
assert testRootFolder != null;
/* create test class(es) for the selected source class: */
DataObject suite = JUnitUtils.createSuiteTest(testRootFolder, targetFolder, name, JUnitTestUtil.getSettingsMap(true));
if (suite != null) {
return Collections.singleton(suite);
} else {
throw new IOException();
}
}
代码示例来源:origin: AlexFalappa/nb-springboot
@Override
public Set<?> instantiate() throws IOException {
File fDir = panel.getComponent().getCreatedFile().getParentFile();
// ensure target folder exists and set it into Templates
fDir.mkdirs();
FileObject foDir = FileUtil.toFileObject(fDir);
Templates.setTargetFolder(wizard, foDir);
// Create file from template
FileObject foTemplate = Templates.getTemplate(wizard);
DataObject doTemplate = DataObject.find(foTemplate);
DataFolder df = DataFolder.findFolder(foDir);
DataObject doCreated = doTemplate.createFromTemplate(df, Templates.getTargetName(wizard));
FileObject foCreated = doCreated.getPrimaryFile();
return Collections.singleton(foCreated);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf
public void storeSettings(Object settings) {
if ( WizardDescriptor.PREVIOUS_OPTION.equals( ((WizardDescriptor)settings).getValue() ) ) {
return;
}
if( isValid() ) {
if ( bottomPanel != null ) {
bottomPanel.storeSettings( settings );
}
FileObject template = Templates.getTemplate( wizard );
String name = gui.getTargetName ();
if (name.indexOf ('/') > 0) { // NOI18N
name = name.substring (name.lastIndexOf ('/') + 1);
}
Templates.setTargetFolder( (WizardDescriptor)settings, getTargetFolderFromGUI () );
Templates.setTargetName( (WizardDescriptor)settings, name );
}
((WizardDescriptor)settings).putProperty ("NewFileWizard_Title", null); // NOI18N
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans
private void addLibrariesToClassPath(Library[] libraries) throws IOException {
FileObject artifact = getSourceGroupArtifact(Templates.getProject(wizard), Templates.getTargetFolder(wizard));
if (artifact != null) {
ProjectClassPathModifier.addLibraries(libraries, artifact, ClassPath.COMPILE);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project
private void setTargetFolder() {
if (Templates.getTargetFolder(wizard) != null) {
// already set
return;
}
if (phpProject == null) {
// not php project
return;
}
FileObject srcDir = ProjectPropertiesSupport.getSourcesDirectory(phpProject);
if (srcDir != null && srcDir.isValid()) {
Templates.setTargetFolder(wizard, srcDir);
}
}
代码示例来源:origin: AlexFalappa/nb-springboot
boolean valid(WizardDescriptor wizardDescriptor) {
if (txBaseName.getText().isEmpty()) {
// Base name not specified
wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Base name cannot be empty!");
return false;
}
File f = getCreatedFile();
if (f.exists()) {
// Existing file
wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "Application properties file exists!");
return false;
}
wizardDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, "");
final FileObject targetFolder = FileUtil.toFileObject(f.getParentFile());
Templates.setTargetFolder(wizardDescriptor, targetFolder);
Templates.setTargetName(wizardDescriptor, f.getName());
return true;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
selectedText = (String) wizard.getProperty("selectedText"); //NOI18N
Project project = Templates.getProject( wizard );
Sources sources = project.getLookup().lookup(org.netbeans.api.project.Sources.class);
Templates.setTargetFolder(wizard, targetFolder);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project
@Override
public void readSettings(WizardDescriptor settings) {
this.settings = settings;
fetchNamespaces(Templates.getTargetFolder(settings));
}
内容来源于网络,如有侵权,请联系作者删除!