本文整理汇总了Java中org.netbeans.spi.project.ui.templates.support.Templates.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java Templates.getProject方法的具体用法?Java Templates.getProject怎么用?Java Templates.getProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.spi.project.ui.templates.support.Templates
的用法示例。
在下文中一共展示了Templates.getProject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
}
示例3: read
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
void read(WizardDescriptor wd) {
boolean isTest = false;
final String location = (String) wd.getProperty(ApplWizardIterator.WIZ_LOCATION);
if (location != null) {
isTest = location.equals("test");
}
final Project project = Templates.getProject(wd);
if (project != null) {
nbProj = project.getLookup().lookup(NbMavenProject.class);
// this will in turn update the resourceFolder field
cbLocation.setSelectedIndex(isTest ? 1 : 0);
}
String baseName = (String) wd.getProperty(ApplWizardIterator.WIZ_BASE_NAME);
if (baseName == null) {
baseName = "application";
}
this.txBaseName.setText(baseName);
this.txBaseName.selectAll();
this.txProfile.setText((String) wd.getProperty(ApplWizardIterator.WIZ_PROFILE));
}
示例4: readSettings
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public void readSettings(WizardDescriptor wiz) {
try {
final Project project = Templates.getProject(wiz);
NbMavenProject nbProj = project.getLookup().lookup(NbMavenProject.class);
final URI[] resources = nbProj.getResources(false);
File resourceFolder = FileUtil.normalizeFile(FileUtil.archiveOrDirForURL(resources[0].toURL()));
File addMeta = new File(resourceFolder, "META-INF/additional-spring-configuration-metadata.json");
if (addMeta.exists()) {
wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, "Existing additional metadata file will be overwritten!");
}
} catch (Exception ex) {
Exceptions.printStackTrace(Exceptions.attachSeverity(ex, Level.WARNING));
}
getComponent().read(wiz);
}
示例5: updateCreatedFileText
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
public static void updateCreatedFileText(WizardDescriptor wizard, JComboBox cbxPackageName,
JTextField txtName, JTextField txtCreatedFile, Language language) {
String ext = language.equals(Language.JAVA) ? ".java" : ".scala";
Project project = Templates.getProject(wizard);
FileObject foTargetFolder = Templates.getTargetFolder(wizard);
String completePath = null;
String packagePart = cbxPackageName.getEditor().getItem().toString().replace(".", "/");
if (foTargetFolder.getPath().contains(project.getProjectDirectory().getPath() + "/app")) {
if (packagePart.isEmpty()) {
completePath = project.getProjectDirectory().getPath() + "/app/" + txtName.getText() + ext;
} else {
completePath = project.getProjectDirectory().getPath() + "/app/" + packagePart + "/" + txtName.getText() + ext;
}
} else if (foTargetFolder.getPath().contains(project.getProjectDirectory().getPath() + "/test")) {
if (packagePart.isEmpty()) {
completePath = project.getProjectDirectory().getPath() + "/test/" + txtName.getText() + ext;
} else {
completePath = project.getProjectDirectory().getPath() + "/test/" + packagePart + "/" + txtName.getText() + ext;
}
}
txtCreatedFile.setText(completePath);
}
示例6: getPanels
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
/**
* Returns the panels.
*
* <p>If something changes dynamically (besides moving between panels), e.g.
* the number of panels changes in response to user input, then use
* ChangeSupport to implement add/removeChangeListener and call fireChange
* when needed.</p>
*
* @return Panels
*/
protected List<WizardDescriptor.Panel<WizardDescriptor>> getPanels()
{
if( panels == null )
{
panels = new ArrayList<>();
Project p = Templates.getProject(wizard);
SourceGroup[] groups = ProjectUtils.getSources(p).getSourceGroups(Sources.TYPE_GENERIC);
WizardDescriptor.Panel<WizardDescriptor> advNewFilePanel =
Templates.buildSimpleTargetChooser(p, groups).bottomPanel(bottomPanel).create();
panels.add(advNewFilePanel);
}
return panels;
}
示例7: 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);
cmp = false;//RelatedCMPWizard.isCMP(wizardDescriptor);
ImportHelper helper = DBImportWizardDescriptor.getHelper(wizardDescriptor);
DBSchemaFileList dbschemaFileList = helper.getDBSchemaFileList();
// PersistenceGenerator persistenceGen = helper.getPersistenceGenerator();
TableSource tableSource = helper.getTableSource();
FileObject targetFolder = Templates.getTargetFolder(wizardDescriptor);
getComponent().initialize(project, dbschemaFileList, null, tableSource, targetFolder);
}
}
示例8: instantiate
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public Set instantiate() throws IOException {
wizard.getProperties();
CacheProject project = (CacheProject) Templates.getProject(wizard);
try {
String rtnName = (String) wizard.getProperty("routineName");
if (!rtnName.isEmpty()) {
rtnName +=".mac";
CacheFileSystem fs = project.getConnection().getFileSystem();
CacheFileObject fo = new CacheFileObject(fs, (CacheFileObject) fs.getRoot(), rtnName);
Database db = fs.getConnection().getAssociatedConnection();
DataObject rdo = DataObject.find(fo);
System.out.println("instantiate: " + fo + " - " + rdo);
return Collections.singleton(fo);
}
} catch (DataObjectNotFoundException ex) {
ex.printStackTrace();
}
return Collections.emptySet();
}
示例9: isValid
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@NbBundle.Messages("noVaadinSupport=Chosen project has no Vaadin support.")
@Override
public boolean isValid() {
if (myDescriptor == null) {
return true;
}
Project project = Templates.getProject(myDescriptor);
VaadinSupport support = project.getLookup().lookup(VaadinSupport.class);
if (support != null && support.isEnabled()) {
return true;
}
else {
myDescriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE,
Bundle.noVaadinSupport());
return false;
}
}
示例10: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public void initialize( WizardDescriptor wizard ) {
myWizard = wizard;
Project project = Templates.getProject(wizard);
SourceGroup[] sourceGroups =
JavaUtils.getJavaSourceGroups(project, true);
myWidgetPanel = new WidgetTypePanel();
WizardDescriptor.Panel<WizardDescriptor> firstPanel =
new FinishableWizardPanel(JavaTemplates.createPackageChooser(
project, sourceGroups, myWidgetPanel, true),
myWidgetPanel);
mySelectPanel = new ComponentSelectPanel(wizard);
myPanels = new WizardDescriptor.Panel[] { firstPanel, mySelectPanel };
setSteps();
}
示例11: 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);
}
}
示例12: instantiate
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public Set instantiate() throws IOException {
FileObject result = generateEntity(
Templates.getTargetFolder(wiz),
Templates.getTargetName(wiz),
ejbPanel.getPrimaryKeyClassName(),
true // setting field access type by default
);
try{
boolean isCreatePU = ejbPanel.isCreatePU();
Project project = Templates.getProject(wiz);
if(isCreatePU)
{
PersistenceUnit punit = Util.buildPersistenceUnitUsingData(project, puPanel.getPersistenceUnitName(), puPanel.getPersistenceConnection()!=null ? puPanel.getPersistenceConnection().getName() : puPanel.getDatasource(), TableGeneration.NONE, puPanel.getSelectedProvider());
ProviderUtil.setTableGeneration(punit, puPanel.getTableGeneration(), puPanel.getSelectedProvider());
if (punit != null){
Util.addPersistenceUnitToProjectRoot( project, result, punit);
}
} else {
Util.addPersistenceUnitToProject( project );
}
addEntityToPersistenceUnit(result);
PersistenceUtils.logUsage(EntityWizard.class, "USG_PERSISTENCE_ENTITY", null);
} catch (InvalidPersistenceXmlException ipx){
// just log for debugging purposes, at this point the user has
// already been warned about an invalid persistence.xml
Logger.getLogger(EntityWizard.class.getName()).log(Level.FINE, "Invalid persistence.xml: " + ipx.getPath(), ipx); //NOI18N
}
return Collections.singleton(result);
}
示例13: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public void initialize (WizardDescriptor wiz) {
this.wiz = (TemplateWizard) wiz;
index = 0;
Project project = Templates.getProject( wiz );
panels = createPanels (project,this.wiz);
// Creating steps.
Object prop = wiz.getProperty (WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
String[] beforeSteps = null;
if (prop != null && prop instanceof String[]) {
beforeSteps = (String[])prop;
}
String[] steps = createSteps (beforeSteps, panels);
for (int i = 0; i < panels.size(); i++) {
Component c = panels.get(i).getComponent ();
if (steps[i] == null) {
// Default step name to component name of panel.
// Mainly useful for getting the name of the target
// chooser to appear in the list of steps.
steps[i] = c.getName ();
}
if (c instanceof JComponent) { // assume Swing components
JComponent jc = (JComponent) c;
// Step #.
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i));
// Step name (actually the whole list for reference).
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
}
}
}
示例14: initialize
import org.netbeans.spi.project.ui.templates.support.Templates; //导入方法依赖的package包/类
@Override
public void initialize(WizardDescriptor wizard) {
this.wiz = wizard;
Project project = Templates.getProject(wiz);
Selenium2SupportImpl selenium2Support = Selenium2Support.findSelenium2Support(project);
if (selenium2Support != null){
panel = selenium2Support.createTargetChooserPanel(wiz);
panel.getComponent();
} else {
wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, Bundle.NO_SELENIUM_SUPPORT(project.getProjectDirectory().toString()));
panel = Templates.buildSimpleTargetChooser(project, new SourceGroup[0]).create();
}
}
示例15: 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);
}
}