org.netbeans.spi.project.ui.templates.support.Templates.getTemplate()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.netbeans.spi.project.ui.templates.support.Templates.getTemplate()方法的一些代码示例,展示了Templates.getTemplate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Templates.getTemplate()方法的具体详情如下:
包路径:org.netbeans.spi.project.ui.templates.support.Templates
类名称:Templates
方法名:getTemplate

Templates.getTemplate介绍

暂无

代码示例

代码示例来源: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: org.netbeans.modules/org-netbeans-modules-j2ee-samples

protected WizardDescriptor.Panel[] createPanels() {
  boolean specifyPrjName = "web".equals(Templates.getTemplate(wiz).getAttribute("prjType")); // NOI18N
  return new WizardDescriptor.Panel[] {
    new JavaEESamplesWizardPanel(false, specifyPrjName)
  };
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-samples

@Override
protected WizardDescriptor.Panel[] createPanels() {
  boolean specifyPrjName = "web".equals(Templates.getTemplate(wiz).getAttribute("prjType"));
  return new WizardDescriptor.Panel[] {
    new JavaEESamplesWizardPanel(true, specifyPrjName)
  };
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core

public String getResultExtension( TargetChooserPanel<T> panel ) {
  return Templates.getTemplate( panel.getTemplateWizard()).getExt();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core

public String getExpectedExtension( TargetChooserPanel<T> panel ) {
  return Templates.getTemplate( panel.getTemplateWizard()).getExt();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core

public String getExpectedExtension( TargetChooserPanel<FileType> panel ) {
  if (isFacelets()) {
    return FACELETS_EXT;    // NOI18N
  }
  else {
    return Templates.getTemplate( panel.getTemplateWizard()).getExt();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-project

public Set<FileObject> instantiate () throws IOException {
  FileObject dir = Templates.getTargetFolder( wiz );
  String targetName = Templates.getTargetName( wiz );
  
  DataFolder df = DataFolder.findFolder( dir );
  FileObject template = Templates.getTemplate( wiz );
  
  FileObject createdFile = null;
  DataObject dTemplate = DataObject.find( template );
  // Work around #109569
  Map<String, Object> props = new HashMap<String, Object>(wiz.getProperties());
  props.remove("project"); // NOI18N
  DataObject dobj = dTemplate.createFromTemplate( df, targetName, props);
  createdFile = dobj.getPrimaryFile();
  
  return Collections.singleton( createdFile );
}

代码示例来源:origin: AlexFalappa/nb-springboot

@Override
public Set<?> instantiate() throws IOException {
  // Create file from template
  String targetName = Templates.getTargetName(wizard);
  FileObject foDir = Templates.getTargetFolder(wizard);
  FileObject foTemplate = Templates.getTemplate(wizard);
  DataObject doTemplate = DataObject.find(foTemplate);
  DataFolder df = DataFolder.findFolder(foDir);
  Map<String, Object> props = new HashMap<>();
  props.put(WIZ_TECHNOLOGY, wizard.getProperty(WIZ_TECHNOLOGY));
  props.put(WIZ_SAMPLE_OPS, wizard.getProperty(WIZ_SAMPLE_OPS));
  DataObject doCreated = doTemplate.createFromTemplate(df, targetName, props);
  FileObject foCreated = doCreated.getPrimaryFile();
  return Collections.singleton(foCreated);
}

代码示例来源:origin: AlexFalappa/nb-springboot

@Override
public Set<?> instantiate() throws IOException {
  // Create file from template
  String targetName = Templates.getTargetName(wizard);
  FileObject foDir = Templates.getTargetFolder(wizard);
  FileObject foTemplate = Templates.getTemplate(wizard);
  DataObject doTemplate = DataObject.find(foTemplate);
  DataFolder df = DataFolder.findFolder(foDir);
  Map<String, Object> props = new HashMap<>();
  props.put(WIZ_ERROR_HANDLING, wizard.getProperty(WIZ_ERROR_HANDLING));
  DataObject doCreated = doTemplate.createFromTemplate(df, targetName, props);
  FileObject foCreated = doCreated.getPrimaryFile();
  return Collections.singleton(foCreated);
}

代码示例来源:origin: AlexFalappa/nb-springboot

@Override
public Set<?> instantiate() throws IOException {
  // Create file from template
  String targetName = Templates.getTargetName(wizard);
  FileObject foDir = Templates.getTargetFolder(wizard);
  FileObject foTemplate = Templates.getTemplate(wizard);
  DataObject doTemplate = DataObject.find(foTemplate);
  DataFolder df = DataFolder.findFolder(foDir);
  Map<String, Object> props = new HashMap<>();
  props.put(WIZ_CRUD_METHODS, wizard.getProperty(WIZ_CRUD_METHODS));
  props.put(WIZ_ERROR_HANDLING, wizard.getProperty(WIZ_ERROR_HANDLING));
  DataObject doCreated = doTemplate.createFromTemplate(df, targetName, props);
  FileObject foCreated = doCreated.getPrimaryFile();
  return Collections.singleton(foCreated);
}

代码示例来源: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-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: AlexFalappa/nb-springboot

@Override
public Set<?> instantiate() throws IOException {
  // Create file from template
  String targetName = Templates.getTargetName(wizard);
  FileObject foDir = Templates.getTargetFolder(wizard);
  FileObject foTemplate = Templates.getTemplate(wizard);
  DataObject doTemplate = DataObject.find(foTemplate);
  DataFolder df = DataFolder.findFolder(foDir);
  Map<String, Object> props = new HashMap<>();
  props.put(WIZ_CRUD_METHODS, wizard.getProperty(WIZ_CRUD_METHODS));
  props.put(WIZ_ERROR_HANDLING, wizard.getProperty(WIZ_ERROR_HANDLING));
  DataObject doCreated = doTemplate.createFromTemplate(df, targetName, props);
  FileObject foCreated = doCreated.getPrimaryFile();
  return Collections.singleton(foCreated);
}

代码示例来源: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-php-project

@Override
public Set<FileObject> instantiate() throws IOException {
  FileObject dir = Templates.getTargetFolder(wizard);
  FileObject template = Templates.getTemplate(wizard);
  DataFolder dataFolder = DataFolder.findFolder(dir);
  DataObject dataTemplate = DataObject.find(template);
  DataObject createdFile = dataTemplate.createFromTemplate(dataFolder, Templates.getTargetName(wizard), getTemplateParams());
  // #187374
  try {
    PhpProjectUtils.reformatFile(createdFile);
  } catch (IOException exc) {
    LOGGER.log(Level.WARNING, exc.getMessage(), exc);
  }
  return Collections.singleton(createdFile.getPrimaryFile());
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project

@Override
public void readSettings(WizardDescriptor settings) {
  this.settings = settings;
  // Try to preselect a folder
  FileObject preselectedFolder = Templates.getTargetFolder(settings);
  // Init values
  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-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: 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-web-core

public String getResultExtension( TargetChooserPanel<FileType> panel ) {
  String ext = Templates.getTemplate( panel.getTemplateWizard()).getExt();
  if ( getUIManager().isSegment()) {
    ext+="f"; //NOI18N
  }
  else if (isFacelets()) {
    ext=FACELETS_EXT; 
  }
  return ext;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-css-prep

@Override
public Set<FileObject> instantiate() throws IOException {
  getBottomPanel().save();
  FileObject dir = Templates.getTargetFolder(wizard);
  FileObject template = Templates.getTemplate(wizard);
  DataFolder dataFolder = DataFolder.findFolder(dir);
  DataObject dataTemplate = DataObject.find(template);
  DataObject createdFile = dataTemplate.createFromTemplate(dataFolder, Templates.getTargetName(wizard));
  return Collections.singleton(createdFile.getPrimaryFile());
}

相关文章