org.netbeans.api.project.ProjectInformation Java Examples
The following examples show how to use
org.netbeans.api.project.ProjectInformation.
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: SendJMSGenerator.java From netbeans with Apache License 2.0 | 6 votes |
private String generateDestinationReference(EnterpriseReferenceContainer container, FileObject referencingFile, String referencingClass) throws IOException { // this may need to generalized later if jms producers are expected // in web modules ProjectInformation projectInformation = ProjectUtils.getInformation(mdbHolderProject); String link = projectInformation.getName() + ".jar#" + messageDestination.getName(); Project referenceingProject = FileOwnerQuery.getOwner(referencingFile); if (mdbHolderProject.equals(referenceingProject)) { link = link.substring(link.indexOf('#') + 1); } MessageDestinationReference ref = MessageDestinationReference.create( messageDestination.getName(), messageDestination.getType() == MessageDestination.Type.QUEUE ? "javax.jms.Queue" : "javax.jms.Topic", PRODUCES, link ); return container.addDestinationRef(ref, referencingFile, referencingClass); }
Example #2
Source File: ProjectCellRenderer.java From netbeans-mmd-plugin with Apache License 2.0 | 6 votes |
@Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { if (!(value instanceof Project)){ return this; } setName("ComboBox.listRenderer"); final ProjectInformation info = ProjectUtils.getInformation((Project)value); setText(info.getDisplayName()); setIcon(info.getIcon()); if (isSelected){ setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); }else{ setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
Example #3
Source File: ClassPathFileChooser.java From netbeans with Apache License 2.0 | 6 votes |
private Node createPackageRootNode(FileObject rootFO, Project project, Filter filter) { Node origNode; try { origNode = DataObject.find(rootFO).getNodeDelegate(); } catch (DataObjectNotFoundException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); return null; } String displayName; Project owner = FileOwnerQuery.getOwner(rootFO); if (owner != null) { SourceGroup g = getSourceGroup(rootFO, owner); displayName = g != null ? g.getDisplayName() : FileUtil.getFileDisplayName(rootFO); if (project != owner) { ProjectInformation pi = ProjectUtils.getInformation(owner); displayName += " [" + pi.getDisplayName() + "]"; // NOI18N } } else displayName = FileUtil.getFileDisplayName(rootFO); return new FilteredNode(origNode, displayName, filter); }
Example #4
Source File: FileDescription.java From netbeans with Apache License 2.0 | 6 votes |
@CheckForNull private ProjectInformation getProjectInfo() { // Issue #167198: A file may not belong to any project. // Hence, FileOwnerQuery.getOwner(file) can return null as a project, // and fileDescription.project will be null too. // But! We should not call ProjectUtils.getInformation(null). if(project == null) { return null; } ProjectInformation res = projectInfo; if (res == null) { //Don't use slow ProjectUtils.getInformation res = projectInfo = project.getLookup().lookup(ProjectInformation.class); } return res; }
Example #5
Source File: TrustProjectPanel.java From netbeans with Apache License 2.0 | 6 votes |
@Messages({ "# {0} = Project name", "TrustProjectPanel.INFO=<html><p>NetBeans is about to invoke a Gradle build process of the project: <b>{0}</b>.</p>" + " <p>Executing Gradle can be potentially un-safe as it" + " allows arbitrary code execution.</p>", "TrustProjectPanel.INFO_UNKNOWN=<html><p>NetBeans is about to invoke a Gradle build process.</p>" + " <p>Executing Gradle can be potentially un-safe as it" + " allows arbitrary code execution.</p>" }) public TrustProjectPanel(Project project) { initComponents(); ProjectInformation info = project != null ? project.getLookup().lookup(ProjectInformation.class) : null; if (project == null) { cbTrustProject.setEnabled(false); cbTrustProject.setVisible(false); } if (info == null) { lbTrustMessage.setText(Bundle.TrustProjectPanel_INFO_UNKNOWN()); } else { lbTrustMessage.setText(Bundle.TrustProjectPanel_INFO(info.getDisplayName())); } }
Example #6
Source File: GroovyTypeSearcher.java From netbeans with Apache License 2.0 | 6 votes |
private void initProjectInfo() { FileObject fo = element.getFileObject(); if (fo != null) { // Findbugs-Removed: File f = FileUtil.toFile(fo); Project p = FileOwnerQuery.getOwner(fo); if (p != null) { ProjectInformation pi = ProjectUtils.getInformation(p); projectName = pi.getDisplayName(); projectIcon = pi.getIcon(); } } else { isLibrary = true; LOGGER.log(Level.FINE, "No fileobject for {0}", element.toString()); } if (projectName == null) { projectName = ""; } }
Example #7
Source File: WizardUtils.java From netbeans with Apache License 2.0 | 6 votes |
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // #93658: GTK needs name to render cell renderer "natively" setName("ComboBox.listRenderer"); // NOI18N String text = null; if (!(value instanceof Project)) { text = value.toString(); } else { ProjectInformation pi = ProjectUtils.getInformation((Project) value); text = pi.getDisplayName(); setIcon(pi.getIcon()); } setText(text); if ( isSelected ) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
Example #8
Source File: Util.java From netbeans with Apache License 2.0 | 6 votes |
/** * Order projects by display name. */ public static Comparator<Project> projectDisplayNameComparator() { return new Comparator<Project>() { private final Collator LOC_COLLATOR = Collator.getInstance(); public int compare(Project o1, Project o2) { ProjectInformation i1 = ProjectUtils.getInformation(o1); ProjectInformation i2 = ProjectUtils.getInformation(o2); int result = LOC_COLLATOR.compare(i1.getDisplayName(), i2.getDisplayName()); if (result != 0) { return result; } else { result = i1.getName().compareTo(i2.getName()); if (result != 0) { return result; } else { return System.identityHashCode(o1) - System.identityHashCode(o2); } } } }; }
Example #9
Source File: CreatedModifiedFilesTest.java From netbeans with Apache License 2.0 | 6 votes |
@RandomlyFails // NB-Core-Build #4355: display name after from bundle expected:<[Much Better Nam]e> but was:<[Testing Modul]e> public void testBundleKeyDefaultBundle() throws Exception { NbModuleProject project = TestBase.generateStandaloneModule(getWorkDir(), "module1"); ProjectInformation pi = ProjectUtils.getInformation(project); assertEquals("display name before from bundle", "Testing Module", pi.getDisplayName()); assertEquals("display name before from project", "Testing Module", project.getBundleInfo().getDisplayName()); CreatedModifiedFiles cmf = new CreatedModifiedFiles(project); Operation op = cmf.bundleKeyDefaultBundle(LocalizedBundleInfo.NAME, "Much Better Name"); assertRelativePath("src/org/example/module1/resources/Bundle.properties", op.getModifiedPaths()); op.run(); pi = ProjectUtils.getInformation(project); assertEquals("display name after from bundle", "Much Better Name", pi.getDisplayName()); assertEquals("display name after from project", "Much Better Name", project.getBundleInfo().getDisplayName()); }
Example #10
Source File: SuiteProjectTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testProjectInformation() throws Exception { SuiteProject p = TestBase.generateSuite(getWorkDir(), "Sweet Stuff"); ProjectInformation i = ProjectUtils.getInformation(p); assertEquals("Sweet_Stuff", i.getName()); assertEquals("Sweet Stuff", i.getDisplayName()); BrandingModel model = new SuiteBrandingModel(new SuiteProperties(p, p.getHelper(), p.getEvaluator(), Collections.<NbModuleProject>emptySet())); model.init(); assertEquals("sweet_stuff", model.getName()); assertEquals("Sweet Stuff", model.getTitle()); TestBase.TestPCL l = new TestBase.TestPCL(); i.addPropertyChangeListener(l); EditableProperties ep = p.getHelper().getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); ep.setProperty("app.name", "sweetness"); ep.setProperty("app.title", "Sweetness is Now!"); p.getHelper().putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); assertEquals(new HashSet<String>(Arrays.asList(ProjectInformation.PROP_NAME, ProjectInformation.PROP_DISPLAY_NAME)), l.changed); assertEquals("Sweet_Stuff", i.getName()); assertEquals("Sweetness is Now!", i.getDisplayName()); model = new SuiteBrandingModel(new SuiteProperties(p, p.getHelper(), p.getEvaluator(), Collections.<NbModuleProject>emptySet())); model.init(); assertEquals("sweetness", model.getName()); assertEquals("Sweetness is Now!", model.getTitle()); }
Example #11
Source File: ProjectNode.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void showJavadoc() { Set<URL> us = findJavadoc(); URL[] urls = us.toArray(new URL[us.size()]); URL pageURL = ShowJavadocAction.findJavadoc("overview-summary.html",urls); if (pageURL == null) { pageURL = ShowJavadocAction.findJavadoc("index.html",urls); } ProjectInformation info = null; Project p = this.antArtifact.getProject (); if (p != null) { info = ProjectUtils.getInformation(p); } ShowJavadocAction.showJavaDoc (pageURL, info == null ? NbBundle.getMessage (ProjectNode.class,"TXT_UnknownProjectName") : info.getDisplayName()); }
Example #12
Source File: ModulesNodeFactory.java From netbeans with Apache License 2.0 | 6 votes |
public SuiteComponentNode(final NbModuleProject suiteComponent) { super(Children.LEAF, Lookups.fixed(new Object[] {suiteComponent})); ProjectInformation info = ProjectUtils.getInformation(suiteComponent); setName(info.getName()); setDisplayName(info.getDisplayName()); setIconBaseWithExtension(NbModuleProject.NB_PROJECT_ICON_PATH); info.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { ImportantFilesNodeFactory.getNodesSyncRP().post(new Runnable() { public void run() { if (ProjectInformation.PROP_DISPLAY_NAME.equals(evt.getPropertyName())) { SuiteComponentNode.this.setDisplayName((String) evt.getNewValue()); } else if (ProjectInformation.PROP_NAME.equals(evt.getPropertyName())) { SuiteComponentNode.this.setName((String) evt.getNewValue()); } } }); } }); }
Example #13
Source File: ProjectInfoImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void configurationXmlChanged(AntProjectEvent ev) { // only interested in changes to nbproject/project.xml if (AntProjectHelper.PROJECT_XML_PATH.equals(ev.getPath())) { // Could be various kinds of changes, but name & displayName might have changed. String oldName; String oldDisplayName; String newName; String newDisplayName; synchronized (guard) { oldName = name; oldDisplayName = displayName; // reset so they are re-read name = null; displayName = null; newName = getName(); newDisplayName = getDisplayName(); } firePropertyChange(ProjectInformation.PROP_NAME, oldName, newName); firePropertyChange(ProjectInformation.PROP_DISPLAY_NAME, oldDisplayName, newDisplayName); } }
Example #14
Source File: QuerySupportTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testAntUpdateHelperProject() throws IOException { AntProjectHelper ah = ProjectGenerator.createProject(projdir, "test"); Project p = ProjectManager.getDefault().findProject(projdir); UpdateImplementation upi = createUpdateImpl(ah); UpdateHelper uh = new UpdateHelper(upi, ah); ProjectInformation pi = QuerySupport.createProjectInformation(uh, p, null); assertEquals("???", pi.getDisplayName()); assertEquals("___", pi.getName()); Element data = uh.getPrimaryConfigurationData(true); Element name = data.getOwnerDocument().createElementNS("urn:test:shared", "name"); name.setTextContent("Test UpdateHelper"); data.appendChild(name); uh.putPrimaryConfigurationData(data, true); assertEquals("Test UpdateHelper", pi.getDisplayName()); assertEquals("Test_UpdateHelper", pi.getName()); }
Example #15
Source File: CordovaPerformer.java From netbeans with Apache License 2.0 | 6 votes |
private boolean hasOtherBuildTool(Project project, String toolfile, String toolName, Runnable r) { if(project.getProjectDirectory().getFileObject(toolfile) != null) { ProjectInformation info = ProjectUtils.getInformation(project); String name = info != null ? info.getDisplayName() : project.getProjectDirectory().getNameExt(); JButton tool = new JButton(toolName); NotifyDescriptor desc = new NotifyDescriptor( Bundle.MSG_SelectBuildTool(name, toolfile, toolName), Bundle.CTL_SelectBuildTool(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.QUESTION_MESSAGE, new Object[] {tool, new JButton("Ant"), NotifyDescriptor.CANCEL_OPTION}, NotifyDescriptor.OK_OPTION); DialogDisplayer.getDefault().notify(desc); if(desc.getValue() == tool) { r.run(); return true; } else if (desc.getValue() == NotifyDescriptor.CANCEL_OPTION) { return true; } } return false; }
Example #16
Source File: ProjectCellRenderer.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // #89393: GTK needs name to render cell renderer "natively" setName("ComboBox.listRenderer"); // NOI18N if (value instanceof Project) { ProjectInformation pi = ProjectUtils.getInformation((Project) value); setText(pi.getDisplayName()); setIcon(pi.getIcon()); } else { setText(value == null ? "" : value.toString()); // NOI18N setIcon(null); } if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
Example #17
Source File: NbProjectInformationProvider.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void propertyChange(PropertyChangeEvent evt) { if (ProjectInformation.PROP_ICON.equals(evt.getPropertyName())) { synchronized (LOCK) { if (!annotatorsInitialized) { annotatorsChanged(); } } updateIcon(true); } else { pcs.firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue()); } }
Example #18
Source File: WebServicesClientSupport.java From netbeans with Apache License 2.0 | 5 votes |
public static void showBrokenAlert(Project project) { ProjectInformation pi = ProjectUtils.getInformation(project); String projectName = null; if(pi !=null) projectName = pi.getDisplayName(); NotifyDescriptor alert = new NotifyDescriptor.Message( NbBundle.getMessage(WebServicesClientSupport.class, "ERR_NoJaxrpcPluginFound", projectName), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notifyLater(alert); }
Example #19
Source File: EarProjectOperations.java From netbeans with Apache License 2.0 | 5 votes |
public void notifyMoved(Project original, File originalPath, final String newName) { if (original == null) { project.getAntProjectHelper().notifyDeleted(); return ; } EarProjectOperations origOperations = original.getLookup().lookup(EarProjectOperations.class); fixLibraryLocation(origOperations); final String oldProjectName = project.getLookup().lookup(ProjectInformation.class).getName(); project.setName(newName); ProjectManager.mutex().writeAccess(new Runnable() { public void run() { AntProjectHelper helper = project.getAntProjectHelper(); EditableProperties projectProps = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); String earName = projectProps.get(EarProjectProperties.JAR_NAME); String oldName = earName.substring(0, earName.length() - 4); if (earName.endsWith(".ear") && oldName.equals(oldProjectName)) { //NOI18N projectProps.put(EarProjectProperties.JAR_NAME, newName + ".ear"); //NOI18N } helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, projectProps); } }); }
Example #20
Source File: DefaultProjectConvertorServices.java From netbeans with Apache License 2.0 | 5 votes |
@Override @NonNull public Icon getIcon() { final ProjectInformation d = delegate; if (d != null) { return d.getIcon(); } else { Icon res = result.getIcon(); //Todo: Handle null res return res; } }
Example #21
Source File: ProjectUtilities.java From netbeans with Apache License 2.0 | 5 votes |
public static Icon getProjectIcon(Lookup.Provider project) { ProjectInformation info = project.getLookup().lookup(ProjectInformation.class); if (info == null) { return new ImageIcon(); } else { return info.getIcon(); } }
Example #22
Source File: FeatureProjectFactory.java From netbeans with Apache License 2.0 | 5 votes |
@Override public String getDisplayName() { ProjectInformation info = delegate.lookup(ProjectInformation.class); if (info != null && info != this) { return info.getDisplayName(); } return getName(); }
Example #23
Source File: FeatureProjectFactory.java From netbeans with Apache License 2.0 | 5 votes |
@Override public String getName() { ProjectInformation info = delegate.lookup(ProjectInformation.class); if (info != null && info != this) { return info.getName(); } return dir.getNameExt(); }
Example #24
Source File: JsIndexSearcher.java From netbeans with Apache License 2.0 | 5 votes |
private void initProjectInfo() { FileObject fo = element.getFileObject(); if (fo != null) { Project p = ProjectConvertors.getNonConvertorOwner(fo); if (p != null) { ProjectInformation pi = ProjectUtils.getInformation(p); projectName = pi.getDisplayName(); projectIcon = pi.getIcon(); } } if (projectName == null) { projectName = ""; } }
Example #25
Source File: JavaTypeProvider.java From netbeans with Apache License 2.0 | 5 votes |
private void initProjectInfo() { Project p = FileOwnerQuery.getOwner(this.rootURI); if (p != null) { final ProjectInformation pi = p.getLookup().lookup(ProjectInformation.class); //Intentionally does not use ProjectUtil.getInformation() as it does slow icon annotation projectName = pi == null ? p.getProjectDirectory().getNameExt() : pi.getDisplayName(); projectIcon = pi == null ? null : pi.getIcon(); } }
Example #26
Source File: UpdateAllProjects.java From netbeans with Apache License 2.0 | 5 votes |
private boolean findNetBeansProject(File destination, EclipseProject requiredProject) throws IOException { for (Project p : OpenProjects.getDefault().getOpenProjects()) { if (requiredProject.getName().equals(p.getLookup().lookup(ProjectInformation.class).getDisplayName())) { return true; } } if (!destination.exists()) { return false; } return ProjectManager.getDefault().findProject(FileUtil.toFileObject(destination)) != null; }
Example #27
Source File: UpdateEclipseReferencePanel.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates new form UpdateEclipseReferencePanel */ private UpdateEclipseReferencePanel(EclipseProjectReference reference) { projName = reference.getProject().getLookup().lookup(ProjectInformation.class).getDisplayName(); initComponents(); eclipseProjectTextField.setText(reference.getEclipseProjectLocation().getPath()); boolean enabled = !(reference.getEclipseProjectLocation().exists() && EclipseUtils.isRegularProject(reference.getEclipseProjectLocation())); eclipseProjectTextField.setEnabled(enabled); browseProjectButton.setEnabled(enabled); enabled = !(reference.getEclipseWorkspaceLocation().exists() && EclipseUtils.isRegularWorkSpace(reference.getEclipseWorkspaceLocation())); eclipseWorkspaceTextField.setText(reference.getEclipseWorkspaceLocation().getPath()); eclipseWorkspaceTextField.setEnabled(enabled); browseWorkspaceButton.setEnabled(enabled); }
Example #28
Source File: DefaultProjectConvertorServices.java From netbeans with Apache License 2.0 | 5 votes |
ProjectInfo( @NonNull final Project project, @NonNull final ProjectConvertor.Result result) { Parameters.notNull("project", project); //NOI18N Parameters.notNull("result", result); //NOI18N this.project = project; this.result = result; this.pcs = new PropertyChangeSupport(this); this.eventSource = project.getLookup().lookupResult(ProjectInformation.class); this.eventSource.addLookupListener(WeakListeners.create(LookupListener.class, this, eventSource)); }
Example #29
Source File: ClassNamePanel.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // #89393: GTK needs name to render cell renderer "natively" setName("ComboBox.listRenderer"); // NOI18N if ( value != null ) { ProjectInformation pi = ProjectUtils.getInformation((Project)value); setText(pi.getDisplayName()); setIcon(pi.getIcon()); } if ( isSelected ) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }
Example #30
Source File: GrailsActionProvider.java From netbeans with Apache License 2.0 | 5 votes |
private void executeSimpleAction(String command) { ProjectInformation inf = ProjectUtils.getInformation(project); String displayName = inf.getDisplayName() + " (" + command + ")"; // NOI18N Callable<Process> callable = ExecutionSupport.getInstance().createSimpleCommand( command, GrailsProjectConfig.forProject(project)); ExecutionDescriptor descriptor = project.getCommandSupport().getDescriptor(command); ExecutionService service = ExecutionService.newService(callable, descriptor, displayName); service.run(); }