本文整理汇总了Java中org.netbeans.spi.project.ui.templates.support.Templates类的典型用法代码示例。如果您正苦于以下问题:Java Templates类的具体用法?Java Templates怎么用?Java Templates使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Templates类属于org.netbeans.spi.project.ui.templates.support包,在下文中一共展示了Templates类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
@Override
public void readSettings(WizardDescriptor wizard) {
this.wizard = wizard;
if ( gui != null ) {
// Try to preselect a folder
FileObject preselectedFolder = Templates.getTargetFolder( wizard );
// Init values
gui.initValues( Templates.getTemplate( wizard ), preselectedFolder );
}
if ( bottomPanel != null ) {
bottomPanel.readSettings(wizard);
}
// XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
// this name is used in NewFileWizard to modify the title
if (gui != null) {
Object substitute = gui.getClientProperty ("NewFileWizard_Title"); // NOI18N
if (substitute != null) {
wizard.putProperty ("NewFileWizard_Title", substitute); // NOI18N
}
}
}
示例2: 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);
}
}
示例3: readSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
@Override
public void readSettings(WizardDescriptor settings) {
wizardDescriptor = settings;
wizardDescriptor.putProperty("NewFileWizard_Title", title); // NOI18N
if (!componentInitialized) {
componentInitialized = true;
project = Templates.getProject(wizardDescriptor);
RelatedCMPHelper helper = RelatedCMPWizard.getHelper(wizardDescriptor);
DBSchemaFileList dbschemaFileList = helper.getDBSchemaFileList();
PersistenceGenerator persistenceGen = helper.getPersistenceGenerator();
TableSource tableSource = helper.getTableSource();
FileObject targetFolder = Templates.getTargetFolder(wizardDescriptor);
getComponent().initialize(project, dbschemaFileList, persistenceGen, tableSource, targetFolder);
}
}
示例4: read
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
public void read(WizardDescriptor settings) {
project = Templates.getProject(settings);
EntityClassScope entityClassScope = EntityClassScope.getEntityClassScope(project.getProjectDirectory());
entityClosure = EntityClosure.create(entityClassScope, project);
entityClosure.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
changeSupport.fireChange();
updateAddAllButton();
}
});
entityClosure.setClosureEnabled(cbAddRelated.isSelected());
listAvailable.setModel(new EntityListModel(entityClosure, true));
listSelected.setModel(new EntityListModel(entityClosure, false));
@SuppressWarnings("unchecked")
List<String> entities = (List<String>) settings.getProperty(WizardProperties.ENTITY_CLASS);
if (entities == null) {
entities = new ArrayList<String>();
}
entityClosure.addEntities(new HashSet<String>(entities));
updateButtons();
updatePersistenceUnitButton();
}
示例5: instantiate
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
@Override
public Set instantiate(ProgressHandle handle) throws IOException {
Project project = Templates.getProject(wiz);
FileObject tFolder = Templates.getTargetFolder(wiz);
try {
handle.start(100);
handle.progress(NbBundle.getMessage(DBScriptWizard.class, "MSG_CreateFile"),5);
FileObject sqlFile = tFolder.createData(Templates.getTargetName(wiz), EXTENSION);//NOI18N
PersistenceEnvironment pe = project.getLookup().lookup(PersistenceEnvironment.class);
if (sqlFile != null) {
//execution
run(project, sqlFile, pe, handle, false);
}
return Collections.singleton(sqlFile);
} finally {
handle.finish();
}
}
示例6: 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);
}
}
示例7: readSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
@Override
public void readSettings(WizardDescriptor settings) {
this.wizard = settings;
TemplateChooserPanelGUI panel = (TemplateChooserPanelGUI) this.getComponent();
final FileObject currentTemplate = Templates.getTemplate(settings);
FileObject templates = FileUtil.getConfigFile("Templates"); //NOI18N
String currentCategoryName = null;
String currentTemplateName = null;
if (templates != null && currentTemplate != null && currentTemplate.getParent() != null && templates.equals(currentTemplate.getParent().getParent())) {
try {
final DataObject dobj = DataObject.find(currentTemplate);
final DataObject owner = DataObject.find(currentTemplate.getParent());
currentTemplateName = dobj.getName();
currentCategoryName = owner.getName();
} catch (DataObjectNotFoundException e) {
//Ignore and use default
}
}
panel.readValues( project, currentCategoryName, currentTemplateName );
settings.putProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, 0);
settings.putProperty(WizardDescriptor.PROP_CONTENT_DATA, new String[] {
NbBundle.getBundle (TemplateChooserPanel.class).getString ("LBL_TemplatesPanel_Name"), // NOI18N
NbBundle.getBundle (TemplateChooserPanel.class).getString ("LBL_TemplatesPanel_Dots")}); // NOI18N
// bugfix #44400: wizard title always changes
settings.putProperty("NewFileWizard_Title", null); // NOI18N
}
示例8: 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
}
示例9: readSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
@Override
public void readSettings(WizardDescriptor wizard) {
this.wizard = wizard;
if (gui != null) {
// Try to preselect a folder
FileObject preselectedFolder = Templates.getTargetFolder(wizard);
// Init values
gui.initValues(Templates.getTemplate(wizard), preselectedFolder);
}
// XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
// this name is used in NewFileWizard to modify the title
if (gui != null) {
Object substitute = gui.getClientProperty ("NewFileWizard_Title"); // NOI18N
if (substitute != null) {
wizard.putProperty ("NewFileWizard_Title", substitute); // NOI18N
}
}
}
示例10: instantiate
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
/**
* This is where, the schema gets instantiated from the template.
*/
public Set instantiate (TemplateWizard wizard) throws IOException {
FileObject dir = Templates.getTargetFolder( wizard );
DataFolder df = DataFolder.findFolder( dir );
FileObject template = Templates.getTemplate( wizard );
DataObject dTemplate = DataObject.find( template );
DataObject dobj = dTemplate.createFromTemplate(df, Templates.getTargetName(wizard));
if (dobj == null)
return Collections.emptySet();
encoding = EncodingUtil.getProjectEncoding(df.getPrimaryFile());
if(!EncodingUtil.isValidEncoding(encoding))
encoding = "UTF-8"; //NOI18N
EditCookie edit = dobj.getCookie(EditCookie.class);
if (edit != null) {
EditorCookie editorCookie = dobj.getCookie(EditorCookie.class);
Document doc = (Document)editorCookie.openDocument();
fixEncoding(doc, encoding);
SaveCookie save = dobj.getCookie(SaveCookie.class);
if (save!=null) save.save();
}
return Collections.singleton(dobj.getPrimaryFile());
}
示例11: createPanels
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
private WizardDescriptor.Panel[] createPanels(final WizardDescriptor wizardDescriptor) {
// Ask for Java folders
Project project = Templates.getProject(wizardDescriptor);
Sources sources = ProjectUtils.getSources(project);
SourceGroup[] groups = getTestRoots(sources);
if (groups.length == 0) {
if (SourceGroupModifier.createSourceGroup(project, JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_HINT_TEST) != null) {
groups = getTestRoots(sources);
}
}
if (groups.length == 0) {
groups = sources.getSourceGroups(Sources.TYPE_GENERIC);
}
return new WizardDescriptor.Panel[]{
JavaTemplates.createPackageChooser(project, groups)
};
}
示例12: instantiate
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
public Set<DataObject> instantiate() throws IOException {
FileObject targetFolder = Templates.getTargetFolder(wiz);
TestNGSupport.findTestNGSupport(FileOwnerQuery.getOwner(targetFolder)).configureProject(targetFolder);
String targetName = Templates.getTargetName(wiz);
DataFolder df = DataFolder.findFolder(targetFolder);
FileObject template = Templates.getTemplate(wiz);
DataObject dTemplate = DataObject.find(template);
String pkgName = getSelectedPackageName(targetFolder);
String suiteName = pkgName + " suite";
String projectName = ProjectUtils.getInformation(FileOwnerQuery.getOwner(targetFolder)).getName();
if (pkgName == null || pkgName.trim().length() < 1) {
pkgName = ".*"; //NOI18N
suiteName = "All tests for " + projectName;
}
Map<String, String> props = new HashMap<String, String>();
props.put("suiteName", projectName);
props.put("testName", suiteName);
props.put("pkg", pkgName);
DataObject dobj = dTemplate.createFromTemplate(df, targetName, props);
return Collections.singleton(dobj);
}
示例13: createPanels
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
private WizardDescriptor.Panel[] createPanels(final WizardDescriptor wizardDescriptor) {
// Ask for Java folders
Project project = Templates.getProject(wizardDescriptor);
Sources sources = ProjectUtils.getSources(project);
SourceGroup[] groups = getTestRoots(sources);
if (groups.length == 0) {
if (SourceGroupModifier.createSourceGroup(project, JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_HINT_TEST) != null) {
groups = getTestRoots(sources);
}
}
if (groups.length == 0) {
groups = sources.getSourceGroups(Sources.TYPE_GENERIC);
return new WizardDescriptor.Panel[]{
Templates.buildSimpleTargetChooser(project, groups).create()
};
} else {
return new WizardDescriptor.Panel[]{
JavaTemplates.createPackageChooser(project, groups, new EmptyTestStepLocation())
};
}
}
示例14: getClassChooserPanel
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
/**
* Returns a panel for choosing name and target location of the test
* class. If the panel already exists, returns the existing panel,
* otherwise creates a new panel.
*
* @return existing panel or a newly created panel if it did not exist
*/
private WizardDescriptor.Panel<WizardDescriptor> getClassChooserPanel() {
final Project project = Templates.getProject(wizard);
if (classChooserPanel == null || project != lastSelectedProject) {
SourceGroupModifier.createSourceGroup(project, JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_HINT_TEST);
final JUnitUtils utils = new JUnitUtils(project);
if (utils.getSourcesToTestsMap(true).isEmpty()) {
classChooserPanel = new StepProblemMessage(
project,
NbBundle.getMessage(EmptyTestCaseWizardIterator.class,
"MSG_NoTestSourceGroup")); //NOI18N
} else {
if (classChooserPanel == null) {
classChooserPanel = new SimpleTestStepLocation();
}
((SimpleTestStepLocation) classChooserPanel).setUp(utils);
}
}
lastSelectedProject = project;
return classChooserPanel;
}
示例15: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入依赖的package包/类
@Override public void initialize(WizardDescriptor templateWizard) {
this.wiz = templateWizard;
String displayName;
try {
displayName = DataObject.find(Templates.getTemplate(wiz)).getNodeDelegate().getDisplayName();
} catch (DataObjectNotFoundException ex) {
displayName = "unknown";
}
String name = displayName;
if (name != null) {
name = name.replaceAll(" ", ""); //NOI18N
}
templateWizard.putProperty (WizardProperties.NAME, name);
basicPanel = new PanelConfigureProject(displayName);
currentIndex = 0;
updateStepsList ();
}