本文整理汇总了Java中org.netbeans.spi.project.ui.templates.support.Templates.setTargetFolder方法的典型用法代码示例。如果您正苦于以下问题:Java Templates.setTargetFolder方法的具体用法?Java Templates.setTargetFolder怎么用?Java Templates.setTargetFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.spi.project.ui.templates.support.Templates
的用法示例。
在下文中一共展示了Templates.setTargetFolder方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public void storeSettings(WizardDescriptor wizard) {
Object value = wizard.getValue();
if (WizardDescriptor.PREVIOUS_OPTION.equals(value) || WizardDescriptor.CANCEL_OPTION.equals(value) ||
WizardDescriptor.CLOSED_OPTION.equals(value)) {
return;
}
if( isValid() ) {
if ( bottomPanel != null ) {
bottomPanel.storeSettings( wizard );
}
Templates.setTargetFolder(wizard, getTargetFolderFromGUI(wizard));
Templates.setTargetName(wizard, gui.getTargetName());
}
if (WizardDescriptor.FINISH_OPTION.equals(value)) {
wizard.putProperty("NewFileWizard_Title", null); // NOI18N
wizard.putProperty(FOLDER_TO_DELETE, null);
}
}
示例2: store
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
void store(WizardDescriptor settings) {
// settings.putProperty(WizardProperties.JSF_FOLDER, jsfFolder.getText());
String pkg = getPackage();
settings.putProperty(WizardProperties.JPA_CONTROLLER_PACKAGE, pkg);
// settings.putProperty(WizardProperties.AJAXIFY_JSF_CRUD, Boolean.valueOf(ajaxifyCheckbox.isSelected()));
try {
FileObject fo = getLocationValue().getRootFolder();
String pkgSlashes = pkg.replace('.', '/');
FileObject targetFolder = fo.getFileObject(pkgSlashes);
if (targetFolder == null) {
targetFolder = FileUtil.createFolder(fo, pkgSlashes);
}
Templates.setTargetFolder(settings, targetFolder);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
示例3: storeSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
public @Override void storeSettings(WizardDescriptor settings) {
if (noProjectFolders()) {
return;
}
if (WizardDescriptor.PREVIOUS_OPTION.equals(settings.getValue())) {
return;
}
if(!WizardDescriptor.CANCEL_OPTION.equals(settings.getValue())
&& !WizardDescriptor.CLOSED_OPTION.equals(settings.getValue()) && isValid()) {
if ( bottomPanel != null ) {
bottomPanel.storeSettings( settings );
}
if ( gui == null ) {
getComponent();
}
String name = gui.getTargetName ();
if (name != null && name.indexOf ('/') > 0) { // NOI18N
name = name.substring (name.lastIndexOf ('/') + 1);
}
Templates.setTargetFolder(settings, getTargetFolderFromGUI());
Templates.setTargetName(settings, name);
}
settings.putProperty("NewFileWizard_Title", null); // NOI18N
}
示例4: valid
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
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;
}
示例5: storeSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public void storeSettings(Object settings) {
WizardDescriptor wizDescriptor = (WizardDescriptor) settings;
SourceGroup sourceGroup = getComponent().getLocationValue();
String packageName = getComponent().getPackageName().trim();
FileObject packageFO = null;
try {
packageFO = SourceGroups.getFolderForPackage(sourceGroup, packageName, true);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
Templates.setTargetFolder(wizDescriptor, packageFO);
Templates.setTargetName(wizDescriptor, getComponent().getScriptName());
}
示例6: storeSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public void storeSettings(Object settings) {
if ( WizardDescriptor.PREVIOUS_OPTION.equals(((WizardDescriptor)settings).getValue())
|| WizardDescriptor.CANCEL_OPTION.equals(((WizardDescriptor)settings).getValue())
|| WizardDescriptor.CLOSED_OPTION.equals(((WizardDescriptor)settings).getValue())) {
return;
}
if( isValid() ) {
File f = new File(myGui.getCreatedFilePath());
File ff = new File(f.getParentFile().getPath());
if ( !ff.exists() ) {
try {
FileUtil.createFolder(ff);
} catch (IOException exc) {
LOG.log(Level.INFO, null, exc);
}
}
FileObject folder = FileUtil.toFileObject(ff);
Templates.setTargetFolder( (WizardDescriptor)settings, folder );
Templates.setTargetName( (WizardDescriptor)settings,
myGui.getTargetName() );
getProvider().storeSettings( this );
}
((WizardDescriptor)settings).putProperty ("NewFileWizard_Title", null); // NOI18N
}
示例7: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
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);
}
}
}
示例8: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
public final void initialize(WizardDescriptor wiz) {
wizardDescriptor = wiz;
project = Templates.getProject(wiz);
String wizardTitle = NbBundle.getMessage(HibernateRevengWizard.class, "Templates/Hibernate/RevEng"); // NOI18N
dbTablesDescriptor = new HibernateRevengDbTablesWizardDescriptor(project, wizardTitle);
if (Templates.getTargetFolder(wiz) == null) {
HibernateFileLocationProvider provider = project != null ? project.getLookup().lookup(HibernateFileLocationProvider.class) : null;
FileObject location = provider != null ? provider.getSourceLocation() : null;
if (location != null) {
Templates.setTargetFolder(wiz, location);
}
}
// Set the targetName here. Default name for new files should be in the form : 'hibernate<i>.reveng.xml
// and not like : hibernate.reveng<i>.xml.
if (wiz instanceof TemplateWizard) {
HibernateEnvironment hibernateEnv = (HibernateEnvironment) project.getLookup().lookup(HibernateEnvironment.class);
// Check for unsupported projects. #142296
if (hibernateEnv == null) {
// Returning without initialization. User will be informed about this using error panel.
return;
}
List<FileObject> revengFiles = hibernateEnv.getAllHibernateReverseEnggFileObjects();
String targetName = DEFAULT_REVENG_FILENAME;
if (!revengFiles.isEmpty() && foundRevengFileInProject(revengFiles, DEFAULT_REVENG_FILENAME)) {
int revengFilesCount = revengFiles.size();
targetName = "hibernate" + (revengFilesCount++) + ".reveng"; //NOI18N
while (foundRevengFileInProject(revengFiles, targetName)) {
targetName = "hibernate" + (revengFilesCount++) + ".reveng"; //NOI18N
}
}
((TemplateWizard) wiz).setTargetName(targetName);
}
}
示例9: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
public void initialize(WizardDescriptor wizard) {
this.wizard = wizard;
project = Templates.getProject(wizard);
String wizardTitle = NbBundle.getMessage(HibernateMappingWizard.class, "LBL_MappingWizardTitle"); // NOI18N
descriptor = new HibernateMappingWizardDescriptor(project, wizardTitle);
if (Templates.getTargetFolder(wizard) == null) {
HibernateFileLocationProvider provider = project != null ? project.getLookup().lookup(HibernateFileLocationProvider.class) : null;
FileObject location = provider != null ? provider.getSourceLocation() : null;
if (location != null) {
Templates.setTargetFolder(wizard, location);
}
}
// Set the targetName here. Default name for the new files should be in the form : 'hibernate<i>.hbm.xml
// and not like : hibernate.hbm<i>.xml
if (wizard instanceof TemplateWizard) {
HibernateEnvironment hibernateEnv = (HibernateEnvironment) project.getLookup().lookup(HibernateEnvironment.class);
// Check for unsupported projects. #142296
if (hibernateEnv == null) {
// Returning without initialization. User will be informed about this using error panel.
return;
}
List<FileObject> mappingFiles = hibernateEnv.getAllHibernateMappingFileObjects();
String targetName = DEFAULT_MAPPING_FILENAME;
if (!mappingFiles.isEmpty() && foundMappingFileInProject(mappingFiles, DEFAULT_MAPPING_FILENAME)) {
int mappingFilesCount = mappingFiles.size();
targetName = "hibernate" + (mappingFilesCount++) + ".hbm"; //NOI18N
while (foundMappingFileInProject(mappingFiles, targetName)) {
targetName = "hibernate" + (mappingFilesCount++) + ".hbm"; //NOI18N
}
}
((TemplateWizard) wizard).setTargetName(targetName);
}
}
示例10: instantiate
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@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);
}
示例11: store
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
void store(WizardDescriptor settings) {
String pkg = getPackage();
try {
FileObject fo = getLocationValue().getRootFolder();
String pkgSlashes = pkg.replace('.', '/');
FileObject targetFolder = fo.getFileObject(pkgSlashes);
if (targetFolder == null) {
targetFolder = FileUtil.createFolder(fo, pkgSlashes);
}
Templates.setTargetFolder(settings, targetFolder);
Templates.setTargetName(wizard, this.getFileName());
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
示例12: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public final void initialize(WizardDescriptor wiz) {
wizardDescriptor = wiz;
project = Templates.getProject(wiz);
helper = new HibernateCodeGenWizardHelper(project);
wiz.putProperty(PROP_HELPER, helper);
String wizardTitle = NbBundle.getMessage(HibernateCodeGenWizard.class, "Templates/Hibernate/CodeGen"); // NOI18N
nameLocationDescriptor = new HibernateCodGenNameLocationWizardDescriptor(project, wizardTitle);
dbTablesDescriptor = new HibernateRevengDbTablesWizardDescriptor(project, wizardTitle);
codeGenDescriptor = new HibernateCodeGenWizardDescriptor(project, wizardTitle);
if (Templates.getTargetFolder(wiz) == null) {
HibernateFileLocationProvider provider = project != null ? project.getLookup().lookup(HibernateFileLocationProvider.class) : null;
FileObject location = provider != null ? provider.getSourceLocation() : null;
if (location != null) {
Templates.setTargetFolder(wiz, location);
}
}
// Set the targetName here. Default name for new files should be in the form : 'hibernate<i>.reveng.xml
// and not like : hibernate.reveng<i>.xml.
if (wiz instanceof TemplateWizard) {
HibernateEnvironment hibernateEnv = (HibernateEnvironment) project.getLookup().lookup(HibernateEnvironment.class);
// Check for unsupported projects. #142296
if (hibernateEnv == null) {
// Returning without initialization. User will be informed about this using error panel.
return;
}
List<FileObject> revengFiles = hibernateEnv.getAllHibernateReverseEnggFileObjects();
String targetName = DEFAULT_REVENG_FILENAME;
if (!revengFiles.isEmpty() && foundRevengFileInProject(revengFiles, DEFAULT_REVENG_FILENAME)) {
int revengFilesCount = revengFiles.size();
targetName = "hibernate" + (revengFilesCount++) + ".reveng"; //NOI18N
while (foundRevengFileInProject(revengFiles, targetName)) {
targetName = "hibernate" + (revengFilesCount++) + ".reveng"; //NOI18N
}
}
((TemplateWizard) wiz).setTargetName(targetName);
}
}
示例13: instantiate
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public Set<?> instantiate() throws IOException {
final Project project = Templates.getProject(wizard);
if (project == null) {
return null;
}
NbMavenProject nbProj = project.getLookup().lookup(NbMavenProject.class);
if (nbProj == null) {
return null;
}
final URI[] resources = nbProj.getResources(false);
if (resources.length == 0) {
return null;
}
try {
Path resourceFolder = FileUtil.archiveOrDirForURL(resources[0].toURL()).toPath();
File fDir = resourceFolder.resolve("META-INF").toFile();
// ensure target folder exists and set it into Templates
fDir.mkdirs();
FileObject foDir = FileUtil.toFileObject(fDir);
Templates.setTargetFolder(wizard, foDir);
// set target name into Templates and delete existing file if it exists
final String targetName = "additional-spring-configuration-metadata.json";
Templates.setTargetName(wizard, targetName);
File fExisting = new File(fDir, targetName);
if (fExisting.exists()) {
fExisting.delete();
}
// create file from template
FileObject foTemplate = Templates.getTemplate(wizard);
DataObject doTemplate = DataObject.find(foTemplate);
DataFolder df = DataFolder.findFolder(foDir);
Map<String, Object> props = new HashMap<>();
props.put(WIZ_SECT_PROPS, wizard.getProperty(WIZ_SECT_PROPS));
props.put(WIZ_SECT_HINTS, wizard.getProperty(WIZ_SECT_HINTS));
props.put(WIZ_SECT_HINTS_VALUES, wizard.getProperty(WIZ_SECT_HINTS_VALUES));
props.put(WIZ_SECT_HINTS_PROVIDERS, wizard.getProperty(WIZ_SECT_HINTS_PROVIDERS));
DataObject doCreated = doTemplate.createFromTemplate(df, targetName, props);
FileObject foCreated = doCreated.getPrimaryFile();
return Collections.singleton(foCreated);
} catch (MalformedURLException ex) {
Exceptions.printStackTrace(ex);
}
return null;
}