org.netbeans.api.project.Project Java Examples
The following examples show how to use
org.netbeans.api.project.Project.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainProjectManager.java From netbeans with Apache License 2.0 | 6 votes |
public Project getMainProject () { final Project lastSelectedProject; final Project current; final boolean isMain; synchronized (this) { lastSelectedProject = lastSelectedProjectRef.get(); current = currentProject.get(); isMain = isMainProject; } if (isMain && lastSelectedProject != null && lastSelectedProject != current && !isDependent(lastSelectedProject, current)) { // If there's a main project set, but the current project has no // dependency on it, return the current project. //System.err.println("getMainProject() = (LS) "+lastSelectedProject); return lastSelectedProject; } else { return current; } //System.err.println("getMainProject() = "+currentProject); }
Example #2
Source File: MavenModelUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** Detect JAX-WS Library in project. * * @param project Project * @return true if library was detected */ public static boolean hasJaxWsAPI(Project project) { SourceGroup[] srcGroups = ProjectUtils.getSources(project).getSourceGroups( JavaProjectConstants.SOURCES_TYPE_JAVA); if (srcGroups.length > 0) { ClassPath classPath = ClassPath.getClassPath(srcGroups[0].getRootFolder(), ClassPath.BOOT); FileObject wsFeature = classPath.findResource("javax/xml/ws/WebServiceFeature.class"); // NOI18N if (wsFeature == null) { classPath = ClassPath.getClassPath(srcGroups[0].getRootFolder(), ClassPath.COMPILE); wsFeature = classPath.findResource("javax/xml/ws/WebServiceFeature.class"); // NOI18N if (wsFeature == null) { return false; } } } return true; }
Example #3
Source File: JaxRsStackSupportImpl.java From netbeans with Apache License 2.0 | 6 votes |
private void removeLibraries(Project project, Collection<URL> urls) { if ( urls.size() >0 ){ SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups( JavaProjectConstants.SOURCES_TYPE_JAVA); if (sourceGroups == null || sourceGroups.length < 1) { return; } FileObject sourceRoot = sourceGroups[0].getRootFolder(); String[] classPathTypes = new String[]{ ClassPath.COMPILE , ClassPath.EXECUTE }; for (String type : classPathTypes) { try { ProjectClassPathModifier.removeRoots(urls.toArray( new URL[ urls.size()]), sourceRoot, type); } catch(UnsupportedOperationException ex) { Logger.getLogger( JaxRsStackSupportImpl.class.getName() ). log (Level.INFO, null , ex ); } catch( IOException e ){ Logger.getLogger( JaxRsStackSupportImpl.class.getName() ). log(Level.INFO, null , e ); } } } }
Example #4
Source File: MissingNbInstallationProblemProvider.java From netbeans with Apache License 2.0 | 6 votes |
public MissingNbInstallationProblemProvider(Project prj) { pchs = new PropertyChangeSupport(this); project = prj; propertyListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (OpenProjects.PROPERTY_OPEN_PROJECTS.equals(evt.getPropertyName()) && OpenProjects.getDefault().isProjectOpen(project)) { pchs.firePropertyChange(PROP_PROBLEMS, null, null); } if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) { pchs.firePropertyChange(PROP_PROBLEMS, null, null); } } }; weak = WeakListeners.propertyChange(propertyListener, this); }
Example #5
Source File: EntityClassesConfigurationPanel.java From jeddict with Apache License 2.0 | 6 votes |
public void initialize(Project project, FileObject targetFolder) { this.project = project; projectTextField.setText(ProjectUtils.getInformation(project).getDisplayName()); SourceGroup[] sourceGroups = getJavaSourceGroups(project); SourceGroupUISupport.connect(locationComboBox, sourceGroups); packageComboBox.setRenderer(PackageView.listRenderer()); updatePackageComboBox(); if (targetFolder != null) { // set default source group and package cf. targetFolder SourceGroup targetSourceGroup = getFolderSourceGroup(sourceGroups, targetFolder); if (targetSourceGroup != null) { locationComboBox.setSelectedItem(targetSourceGroup); String targetPackage = getPackageForFolder(targetSourceGroup, targetFolder); if (targetPackage != null) { packageComboBoxEditor.setText(targetPackage); } } } }
Example #6
Source File: FacesComponentPanel.java From netbeans with Apache License 2.0 | 6 votes |
@Messages({ "FacesComponentPanel.err.jsf.version.not.suficient=Minimal required JSF version for this feature is JSF 2.2" }) @Override public boolean isValid() { getComponent(); descriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, " "); //NOI18N Project project = Templates.getProject(descriptor); WebModule webModule = WebModule.getWebModule(project.getProjectDirectory()); if (webModule != null) { JSFVersion jsfVersion = JSFVersion.forWebModule(webModule); if (jsfVersion != null && !jsfVersion.isAtLeast(JSFVersion.JSF_2_2)) { descriptor.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, Bundle.FacesComponentPanel_err_jsf_version_not_suficient()); return false; } } return true; }
Example #7
Source File: ActionsUtilTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testCanBeReclaimedWithSimpleLookup() throws Exception { Project prj1 = new DummyProject(); Project prj2 = new DummyProject(); Lookup projects = Lookups.fixed(new Object[] { prj1, prj2, }); ActionsUtil.getProjectsFromLookup(projects, null); WeakReference<?> ref1 = new WeakReference<Object>(prj1); WeakReference<?> ref2 = new WeakReference<Object>(prj2); WeakReference<?> lookup = new WeakReference<Object>(projects); prj1 = null; prj2 = null; projects = null; assertGC("the projects can be reclaimed", ref1); assertGC("the projects can be reclaimed", ref2); assertGC("the lookup can be reclaimed", lookup); }
Example #8
Source File: PageIteratorValidation.java From netbeans with Apache License 2.0 | 6 votes |
@NbBundle.Messages({ "JsfJspValidatorPanel.warn.document.root=Project has no valid DocumentRoot" }) @Override public boolean isValid() { Project project = getProject(); if (super.isValid()) { // check that that project has valid document root WebModule webModule = WebModule.getWebModule(project.getProjectDirectory()); if (webModule != null && webModule.getDocumentBase() == null) { getWizardDescriptor().putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, Bundle.JsfJspValidatorPanel_warn_document_root()); } return true; } return false; }
Example #9
Source File: TestNGOutputReaderTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testMsgLogged() throws IOException { FileObject root = FileUtil.toFileObject(getWorkDir()); Project p = new ProjectImpl(root, Lookups.fixed(new LineConvertors.FileLocator() { public FileObject find(String filename) { return null; } })); TestNGTestSession ts = new TestNGTestSession("UnitTest", p, TestSession.SessionType.TEST); TestNGOutputReader r = new TestNGOutputReader(ts); BufferedReader br = new BufferedReader( new FileReader(new File(getDataDir(), "antOut/log.txt"))); String line; while ((line = br.readLine()) != null) { if (line.startsWith(RegexpUtils.TEST_LISTENER_PREFIX)) { r.verboseMessageLogged(line); } } assertEquals(23115, ts.getSessionResult().getElapsedTime()); assertEquals(0, ts.getSessionResult().getErrors()); assertEquals(0, ts.getSessionResult().getFailed()); System.out.println(ts.getSessionResult().getPassed()); System.out.println(ts.getSessionResult().getTotal()); }
Example #10
Source File: LogicalViewProviders.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Node findPath(Node root, Object target) { Project prj = root.getLookup().lookup(Project.class); if (prj == null) { return null; } if (target instanceof FileObject) { FileObject fo = (FileObject) target; if (isOtherProjectSource(fo, prj)) { return null; // Don't waste time if project does not own the fo among sources } for (Node n : root.getChildren().getNodes(true)) { Node result = PackageView.findPath(n, target); if (result != null) { return result; } } } return null; }
Example #11
Source File: MainProjectAction.java From netbeans with Apache License 2.0 | 6 votes |
@SuppressWarnings("LeakingThisInConstructor") MainProjectAction(String command, ProjectActionPerformer performer, String name, Icon icon, Lookup lookup) { super(icon, lookup, new Class<?>[] {Project.class, DataObject.class}); this.command = command; this.performer = performer; this.name = name; String presenterName = ""; if (name != null) { presenterName = MessageFormat.format(name, -1); } setDisplayName(presenterName); if ( icon != null ) { setSmallIcon( icon ); } // Start listening on open projects list to correctly enable the action OpenProjectList.getDefault().addPropertyChangeListener( WeakListeners.propertyChange( this, OpenProjectList.getDefault() ) ); // XXX #47160: listen to changes in supported commands on current project, when that becomes possible }
Example #12
Source File: J2eeProjectCapabilities.java From netbeans with Apache License 2.0 | 5 votes |
@CheckForNull public static J2eeProjectCapabilities forProject(@NonNull Project project) { J2eeModuleProvider provider = project.getLookup().lookup(J2eeModuleProvider.class); if (provider == null) { return null; } Profile ejbJarProfile = null; Profile webProfile = null; Profile carProfile = null; if (provider.getJ2eeModule().getType() == J2eeModule.Type.EJB || provider.getJ2eeModule().getType() == J2eeModule.Type.WAR) { EjbJar[] ejbJars = EjbJar.getEjbJars(project); if (ejbJars.length > 0) { // just use first one to test profile: ejbJarProfile = ejbJars[0].getJ2eeProfile(); } if (provider.getJ2eeModule().getType() == J2eeModule.Type.WAR) { WebModule module = WebModule.getWebModule(project.getProjectDirectory()); if (module != null) { webProfile = module.getJ2eeProfile(); } } } if (provider.getJ2eeModule().getType() == J2eeModule.Type.CAR) { Car car = Car.getCar(project.getProjectDirectory()); if (car != null) { carProfile = car.getJ2eeProfile(); } } return new J2eeProjectCapabilities(project, provider, ejbJarProfile, webProfile, carProfile); }
Example #13
Source File: AbstractLogicalViewProvider.java From netbeans with Apache License 2.0 | 5 votes |
protected AbstractLogicalViewProvider(Project project, UpdateHelper helper, PropertyEvaluator evaluator, ReferenceHelper resolver, J2eeModuleProvider j2eeModuleProvider) { this.project = project; assert project != null; this.helper = helper; assert helper != null; this.evaluator = evaluator; assert evaluator != null; this.resolver = resolver; assert j2eeModuleProvider != null; registerListeners(j2eeModuleProvider); }
Example #14
Source File: AppClientJaxWsOpenHook.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of AppClientJaxWsOpenHook */ public AppClientJaxWsOpenHook(Project prj) { this.prj = prj; try { Class.forName(WSUtils.class.getName()); } catch (ClassNotFoundException e) { assert false; } }
Example #15
Source File: GoalsPanel.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { Project project = FileOwnerQuery.getOwner(Utilities.toURI(new File(gradleProject.getProjectPath()))); if (project != null) { GradleCommandExecutor executor = project.getLookup().lookup(GradleCommandExecutor.class); if (executor != null) { executor.executeCommand(gradleTask); } } }
Example #16
Source File: JFXRunCategoryProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Category createCategory(Lookup context) { boolean fxProjectEnabled = true; final Project project = context.lookup(Project.class); if (project != null) { final J2SEPropertyEvaluator j2sepe = project.getLookup().lookup(J2SEPropertyEvaluator.class); fxProjectEnabled = JFXProjectProperties.isTrue(j2sepe.evaluator().getProperty(JFXProjectProperties.JAVAFX_ENABLED)) //NOI18N && !JFXProjectProperties.isTrue(j2sepe.evaluator().getProperty(JFXProjectProperties.JAVAFX_PRELOADER)); //NOI18N } if(fxProjectEnabled) { return ProjectCustomizer.Category.create(CAT_RUN, NbBundle.getMessage(JFXRunCategoryProvider.class, "LBL_Category_Run"), null); //NOI18N } return null; }
Example #17
Source File: DefaultPlugin.java From netbeans with Apache License 2.0 | 5 votes |
private void loadJUnitToUseFromPropertiesFile(Project project) { final FileObject projectDir = project.getProjectDirectory(); ProjectManager.mutex().postReadRequest(new Runnable() { @Override public void run() { try { Properties props = getProjectProperties(projectDir); String property = props.getProperty(PROP_JUNIT_SELECTED_VERSION); junitVer = property == null ? null : (property.equals("3") ? JUnitVersion.JUNIT3 : property.equals("4") ? JUnitVersion.JUNIT4 : JUnitVersion.JUNIT5); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }); }
Example #18
Source File: SubprojectProviderImpl.java From netbeans with Apache License 2.0 | 5 votes |
private void addKnownOwners(Set<Project> resultset) { List<Artifact> compileArtifacts = project.getLookup().lookup(NbMavenProject.class).getMavenProject().getCompileArtifacts(); for (Artifact ar : compileArtifacts) { File f = ar.getFile(); if (f != null) { Project p = MavenFileOwnerQueryImpl.getInstance().getOwner(Utilities.toURI(f)); if (p != null) { resultset.add(p); } } } }
Example #19
Source File: FormBeanNewPanelVisual.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates new form PropertiesPanelVisual */ public FormBeanNewPanelVisual(Project proj) { initComponents(); jComboBoxSuperclass.getModel().addListDataListener(this); WebModule wm = WebModule.getWebModule(proj.getProjectDirectory()); if (wm!=null){ String[] configFiles = StrutsConfigUtilities.getConfigFiles(wm.getDeploymentDescriptor()); jComboBoxConfigFile.setModel(new javax.swing.DefaultComboBoxModel(configFiles)); } // this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FormBeanNewPanelVisual.class, "ACS_BeanFormProperties")); // NOI18N }
Example #20
Source File: PersistenceXMLGeneratorService.java From jeddict with Apache License 2.0 | 5 votes |
@Override public void generate(ITaskSupervisor task, Project project, SourceGroup sourceGroup, EntityMappings entityMappings) { List<String> classNames = getPUXMLEntries() .stream() .map(classDef -> classDef.getClassHelper().getFQClassName()) .collect(toList()); Lookup.getDefault() .lookup(IPersistenceXMLGenerator.class) .generatePersistenceXML(task, project, sourceGroup, entityMappings, classNames); }
Example #21
Source File: BowerInstallAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Action createContextAwareInstance(Lookup context) { Project contextProject = context.lookup(Project.class); BowerJson bowerJson = null; if (contextProject != null) { // project action bowerJson = new BowerJson(contextProject.getProjectDirectory()); } else { // package.json directly FileObject file = context.lookup(FileObject.class); if (file == null) { DataObject dataObject = context.lookup(DataObject.class); if (dataObject != null) { file = dataObject.getPrimaryFile(); } } if (file != null) { bowerJson = new BowerJson(file.getParent()); } } if (bowerJson == null) { return this; } if (!bowerJson.exists()) { return this; } if (bowerJson.getDependencies().isEmpty()) { return this; } return new BowerInstallAction(contextProject != null ? contextProject : FileOwnerQuery.getOwner(Utilities.toURI(bowerJson.getFile()))); }
Example #22
Source File: J2EEProjectProfilingSupportProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean isFileObjectSupported(FileObject file) { Project project = getProject(); return ((WebProjectUtils.isJSP(file) && WebProjectUtils.isWebDocumentSource(file, project)) // jsp from /web directory || (WebProjectUtils.isHttpServlet(file) && WebProjectUtils.isWebJavaSource(file, project) /*&& WebProjectUtils.isMappedServlet(file, project, true)*/) // mapped servlet from /src directory /*|| super.isFileObjectSupported(file)*/); // regular java file }
Example #23
Source File: ProjectHelper.java From netbeans with Apache License 2.0 | 5 votes |
private static void saveProperty(Project prj, String filePath, String name, String value) { AntProjectHelper aph = getAntProjectHelper(prj); EditableProperties ep = aph.getProperties(filePath); if (value != null) { ep.put(name, value); aph.putProperties(filePath, ep); } }
Example #24
Source File: IncompleteClassPath.java From netbeans with Apache License 2.0 | 5 votes |
@Override @NonNull public List<Fix> run(CompilationInfo compilationInfo, String diagnosticKey, int offset, TreePath treePath, Data<Void> data) { final FileObject file = compilationInfo.getFileObject(); if (file != null) { final Project prj = FileOwnerQuery.getOwner(file); if (prj != null) { return Collections.<Fix>singletonList (new ResolveFix(prj)); } } return Collections.<Fix>emptyList(); }
Example #25
Source File: ResourcesHelper.java From netbeans with Apache License 2.0 | 5 votes |
static private J2eeModuleProvider getProvider(Project project) { J2eeModuleProvider provider = null; if (project != null) { org.openide.util.Lookup lookup = project.getLookup(); provider = lookup.lookup(J2eeModuleProvider.class); } return provider; }
Example #26
Source File: ActiveBrowserAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void stateChanged(ChangeEvent e) { Project p = getCurrentProject(); ProjectBrowserProvider pbp = null; if (p != null) { pbp = p.getLookup().lookup(ProjectBrowserProvider.class); } updateButton(pbp); }
Example #27
Source File: NodeJsSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** * Checks whether node.js support is present and enabled in the given project. * @param project project to be checked * @return {@code true} if node.js support is present and enabled in the given project, {@code false} otherwise */ public boolean isEnabled(@NonNull Project project) { Parameters.notNull("project", project); // NOI18N org.netbeans.modules.javascript.nodejs.platform.NodeJsSupport projectNodeJsSupport = getProjectNodeJsSupport(project); return projectNodeJsSupport != null && projectNodeJsSupport.getPreferences().isEnabled(); }
Example #28
Source File: WSUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static boolean isEJB(Project project) { J2eeModuleProvider j2eeModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class); if (j2eeModuleProvider != null) { J2eeModule.Type moduleType = j2eeModuleProvider.getJ2eeModule().getType(); if (J2eeModule.Type.EJB.equals(moduleType)) { return true; } } return false; }
Example #29
Source File: SpringScope.java From netbeans with Apache License 2.0 | 5 votes |
/** * Returns the reference to the {@code MetadataModel<SpringModel>} of Spring * annotation support. * * @param fo any file inside project; never null. * @return {@code MetadataModel<SpringModel>} of annotation model; never null */ public MetadataModel<SpringModel> getSpringAnnotationModel(FileObject fo) { if (springAnnotationModel == null) { Project project = getSpringProject(fo); if (project == null) { return null; } SpringMetaModelSupport metaModelSupport = new SpringMetaModelSupport(project); springAnnotationModel = metaModelSupport.getMetaModel(); } return springAnnotationModel; }
Example #30
Source File: ResourceLibraryIteratorPanelVisual.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates new form ResourceLibraryIteratorPanelVisual. */ public ResourceLibraryIteratorPanelVisual(Project project, FileObject contractsParent, ProjectType projectType) { this.project = project; this.contractsParent = contractsParent; this.projectType = projectType; initComponents(); initPanelDefaultValues(); initTemplatesPanel(); initListeners(); }