Java Code Examples for org.netbeans.api.project.ProjectUtils#getInformation()

The following examples show how to use org.netbeans.api.project.ProjectUtils#getInformation() . 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: ClassPathFileChooser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 2
Source File: SendJMSGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 3
Source File: Util.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * 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 4
Source File: SourcesTabs.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void setProjectTitle(Project p) {
    if (p == null) {
        setTitleAt(0, NbBundle.getMessage(SourcesTabs.class, "LBL_SourcesTabbs.Current"));
    } else {
        ProjectInformation pi = ProjectUtils.getInformation(p);
        setTitleAt(0, pi.getDisplayName());
    }
}
 
Example 5
Source File: SelectAppServerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateProjectLbl() {
    ProjectInformation pi = ProjectUtils.getInformation(project);
    if (pi != null) {
        lblProject.setText(NbBundle.getMessage(SelectAppServerPanel.class,
                "MSG_InProject", pi.getDisplayName()));
    }
}
 
Example 6
Source File: SearchForProjectsQuickSearch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void evaluate(SearchRequest request, SearchResponse response) {
    final String searchText = request.getText().toLowerCase();

    for (final Project project : OpenProjects.getDefault().getOpenProjects()) {
        final ProjectInformation info = ProjectUtils.getInformation(project);
        if (info == null || info.getDisplayName() == null) {
            continue;
        }
        final String projectName = info.getDisplayName();
        final String projectNameLower = projectName.toLowerCase();

        if (projectNameLower.contains(searchText)) {
            final boolean result = response.addResult(new Runnable() {
                @Override
                public void run() {
                    //see http://forums.netbeans.org/post-140855.html#140855
                    ProjectUtilities.selectAndExpandProject(project);
                    ProjectUtilities.makeProjectTabVisible();
                }
            }, projectName);
            if (!result) {
                break;
            }
        }
    }
}
 
Example 7
Source File: ProjectTreeElement.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates a new instance of ProjectTreeElement */
public ProjectTreeElement(Project prj) {
    ProjectInformation pi = ProjectUtils.getInformation(prj);
    name = pi.getDisplayName();
    icon = pi.getIcon();
    this.prj = new WeakReference<Project>(prj);
    prjDir = prj.getProjectDirectory();
}
 
Example 8
Source File: GrailsActionProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 9
Source File: ProjectNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ProjectInformation getProjectInformation () {
    Project p = this.antArtifact.getProject();
    if (p != null) {
        return ProjectUtils.getInformation(p);
    }
    return null;
}
 
Example 10
Source File: ProjectTreeElement.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ProjectTreeElement(Project project) {
    ProjectInformation projectInformation = ProjectUtils.getInformation(project);
    name = projectInformation.getDisplayName();
    icon = projectInformation.getIcon();
    projectReference = new WeakReference<>(project);
    projectDirectory = project.getProjectDirectory();
}
 
Example 11
Source File: WebServicesSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public 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(WebServicesSupport.class, 
            "ERR_NoJaxrpcPluginFound", projectName), NotifyDescriptor.WARNING_MESSAGE);
    DialogDisplayer.getDefault().notifyLater(alert);
}
 
Example 12
Source File: SearchScopeMainProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Icon getIcon() {
    Project p = OpenProjects.getDefault().getMainProject();
    if (p != null) {
        ProjectInformation pi = ProjectUtils.getInformation(p);
        if (pi != null) {
            return pi.getIcon();
        }
    }
    return null;
}
 
Example 13
Source File: View.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public RootNode(FreeformProject p) {
    super(NodeFactorySupport.createCompositeChildren(p, "Projects/org-netbeans-modules-ant-freeform/Nodes"), Lookups.singleton(p));
    this.p = p;
    info = ProjectUtils.getInformation(p);
    info.addPropertyChangeListener(WeakListeners.propertyChange(this, info));
}
 
Example 14
Source File: ActionProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages({                
    "# {0} - project display name", "TXT_CompilerTooOld=<html>Project {0} contains module-info.java, but modules need maven-compiler-plugin >= 3.6.<br/>Update your pom.xml?</html>"
})
private boolean checkCompilerPlugin(final String action) {
    if (action.equals(ActionProvider.COMMAND_BUILD) || 
        action.equals(ActionProvider.COMMAND_DEBUG) ||
        action.equals(ActionProvider.COMMAND_PROFILE) ||
        action.equals(ActionProvider.COMMAND_REBUILD) ||
        action.equals(ActionProvider.COMMAND_RUN) ||
        action.equals(ActionProvider.COMMAND_TEST)) 
    {
        if (!ModuleInfoUtils.checkModuleInfoAndCompilerFit(proj)) {
            if (NbPreferences.forModule(ActionProviderImpl.class).getBoolean(SHOW_COMPILER_TOO_OLD_WARNING, true)) {
                ProjectInformation info = ProjectUtils.getInformation(proj);
                WarnPanel pnl = new WarnPanel(TXT_CompilerTooOld(info.getDisplayName()));
                Object o = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(pnl, TIT_RequiresUpdateOfPOM(), NotifyDescriptor.YES_NO_OPTION));
                if (pnl.disabledWarning()) {
                    NbPreferences.forModule(ActionProviderImpl.class).putBoolean(SHOW_COMPILER_TOO_OLD_WARNING, false);
                }
                if (o == NotifyDescriptor.YES_OPTION) {
                    RequestProcessor.getDefault().post(() -> {
                        Utilities.performPOMModelOperations(
                                proj.getProjectDirectory().getFileObject("pom.xml"),
                                Collections.singletonList(new UpdateCompilerOperation()));                            
                    });
                    return false; // false means do not continue
                }
            }                
        }
    }
    return true;
}
 
Example 15
Source File: WebServicesClientSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 16
Source File: FreeformProjectTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testProjectInformation() throws Exception {
    ProjectInformation info = ProjectUtils.getInformation(simple);
    assertEquals("correct name", "Simple_Freeform_Project", info.getName());
    assertEquals("same display name", "Simple Freeform Project", info.getDisplayName());
    // XXX test changes
}
 
Example 17
Source File: ProjectsView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ProjectNode(Project p, Children children) {
    super(children, Lookups.singleton(p));
    info = ProjectUtils.getInformation(p);

    setProperties();
}
 
Example 18
Source File: JavaEEProjectSettings.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public String getMessage() {
    ProjectInformation information = ProjectUtils.getInformation(project);
    return "Project " + information.getDisplayName() + " doesn't support JavaEEProjectSettings. " //NOI18N
            + "Add implementation of JavaEEProjectSettingsImplementation into its Project Type lookup."; //NOI18N
}
 
Example 19
Source File: GradleDaemonExecutor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private String getProjectName() {
    ProjectInformation info = ProjectUtils.getInformation(config.getProject());
    return info.getDisplayName();
}
 
Example 20
Source File: AddDependencyUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public OpenProjectNode(Project project) {
    super(Children.LEAF, Lookups.singleton(project));
    pi = ProjectUtils.getInformation(project);
}