NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

[MODULE]Get main project and get its git information

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers
View previous topic :: View next topic  
Author Message
Gabriele



Joined: 31 Jan 2017
Posts: 1
Location: Italy

PostPosted: Tue Jan 31, 2017 12:21 pm    Post subject: [MODULE]Get main project and get its git information Reply with quote

I'm using this code to get the selected project, but getMainProject always returns null so it falls back to getting all projects.
Code:
 Project[] projects;
 Project project = OpenProjects.getDefault().getMainProject();
 projects = project == null ? OpenProjects.getDefault().getOpenProjects() : new Project[]{project};
 for (Project p : projects) {
   ProjectInformation info = ProjectUtils.getInformation(p);
   System.out.println(info.getName());
 }

After that, I want to extract the project's credentials and info to connect to the repository. I couldn't find any example or hint on how to do that.
Can anyone set me in the right direction?
Back to top
markiewb



Joined: 29 Aug 2012
Posts: 870

PostPosted: Thu Feb 02, 2017 6:29 pm    Post subject: [MODULE]Get main project and get its git information Reply with quote

What do you think is the main project? The main can be set via Run->Set Main Project 

I guess this info not what you to read. So what is the use case behind your question? 


Den 2 feb. 2017 14:00 skrev "Gabriele" <address-removed ([email]address-removed[/email])>:
Quote:
I'm using this code to get the selected project, but getMainProject always returns null so it falls back to getting all projects.

Code:
 Project[] projects;
 Project project = OpenProjects.getDefault().getMainProject();
 projects = project == null ? OpenProjects.getDefault().getOpenProjects() : new Project[]{project};
 for (Project p : projects) {
   ProjectInformation info = ProjectUtils.getInformation(p);
   System.out.println(info.getName());
 }



After that, I want to extract the project's credentials and info to connect to the repository. I couldn't find any example or hint on how to do that.
Can anyone set me in the right direction?




Back to top
markiewb



Joined: 29 Aug 2012
Posts: 870

PostPosted: Thu Feb 02, 2017 6:32 pm    Post subject: [MODULE]Get main project and get its git information Reply with quote

I read your mail again. Have a look at my old Plugin https://github.com/markiewb/nb-git-branch-in-statusbar





Den 2 feb. 2017 19:28 skrev "Benno Markiewicz" <address-removed ([email]address-removed[/email])>:
Quote:
What do you think is the main project? The main can be set via Run->Set Main Project 

I guess this info not what you to read. So what is the use case behind your question? 


Den 2 feb. 2017 14:00 skrev "Gabriele" <address-removed ([email]address-removed[/email])>:
Quote:
I'm using this code to get the selected project, but getMainProject always returns null so it falls back to getting all projects.

Code:
 Project[] projects;
 Project project = OpenProjects.getDefault().getMainProject();
 projects = project == null ? OpenProjects.getDefault().getOpenProjects() : new Project[]{project};
 for (Project p : projects) {
   ProjectInformation info = ProjectUtils.getInformation(p);
   System.out.println(info.getName());
 }



After that, I want to extract the project's credentials and info to connect to the repository. I couldn't find any example or hint on how to do that.
Can anyone set me in the right direction?






Back to top
brett.ryan



Joined: 25 Feb 2011
Posts: 238
Location: Melbourne, Australia

PostPosted: Thu Feb 02, 2017 6:42 pm    Post subject: [MODULE]Get main project and get its git information Reply with quote

I think the assumption would be that it would return itself if there is no main project set?


Is this true for maven projects though? You can not set the main so should it return the parent or should a main be set?

On 3 Feb 2017, at 05:28, Benno Markiewicz <address-removed ([email]address-removed[/email])> wrote:


Quote:
What do you think is the main project? The main can be set via Run->Set Main Project

I guess this info not what you to read. So what is the use case behind your question?


Den 2 feb. 2017 14:00 skrev "Gabriele" <address-removed ([email]address-removed[/email])>:
Quote:
I'm using this code to get the selected project, but getMainProject always returns null so it falls back to getting all projects.

Code:
Project[] projects;
Project project = OpenProjects.getDefault().getMainProject();
projects = project == null ? OpenProjects.getDefault().getOpenProjects() : new Project[]{project};
for (Project p : projects) {
ProjectInformation info = ProjectUtils.getInformation(p);
System.out.println(info.getName());
}



After that, I want to extract the project's credentials and info to connect to the repository. I couldn't find any example or hint on how to do that.
Can anyone set me in the right direction?







Back to top
smetz100
Posted via mailing list.





PostPosted: Thu Feb 02, 2017 10:57 pm    Post subject: [MODULE]Get main project and get its git information Reply with quote

please forward all future [nbdev] comments to address-removed. Please remove address-removed from your correspondence. Regards. Steve Metz



From: Brett Ryan <address-removed>
To: address-removed
Sent: Thursday, February 2, 2017 11:41 AM
Subject: [nbdev] Re: [MODULE]Get main project and get its git information



I think the assumption would be that it would return itself if there is no main project set?

Is this true for maven projects though? You can not set the main so should it return the parent or should a main be set?
On 3 Feb 2017, at 05:28, Benno Markiewicz <address-removed ([email]address-removed[/email])> wrote:

Quote:
What do you think is the main project? The main can be set via Run->Set Main Project
I guess this info not what you to read. So what is the use case behind your question?

Den 2 feb. 2017 14:00 skrev "Gabriele" <address-removed ([email]address-removed[/email])>:
Quote:
I'm using this code to get the selected project, but getMainProject always returns null so it falls back to getting all projects. Code: Project[] projects; Project project = OpenProjects.getDefault(). getMainProject(); projects = project == null ? OpenProjects.getDefault(). getOpenProjects() : new Project[]{project}; for (Project p : projects) { ProjectInformation info = ProjectUtils.getInformation(p) ; System.out.println(info. getName()); } After that, I want to extract the project's credentials and info to connect to the repository. I couldn't find any example or hint on how to do that. Can anyone set me in the right direction?



Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo