本文整理汇总了Java中org.eclipse.egit.github.core.Label类的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Label类属于org.eclipse.egit.github.core包,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePrintIssue
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
private void handlePrintIssue(int issueId) {
try {
Issue issue = new IssueService().getIssue(githubUser, githubRepo, issueId);
String labelStr = "";
List<Label> labels = issue.getLabels();
for (int i=0; i<labels.size(); i++) {
labelStr += labels.get(i);
labelStr += (i < labels.size()-1) ? ", " : "";
}
sendAndLog("Issue #" + issueId + " (" + issue.getState() + "): "+ issue.getTitle());
sendAndLog("Created at " + issue.getCreatedAt() + " by " + issue.getUser().getName() + ", " + issue.getComments() + " comment(s), labels: " + labelStr);
sendAndLog(issue.getHtmlUrl());
}
catch (IOException e) {
e.printStackTrace();
}
}
示例2: addLabelsToIssue
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
private List<Label> addLabelsToIssue(String id, String issueId, List<Label> labels)
throws IOException {
if (issueId == null) {
throw new IllegalArgumentException("Issue id cannot be null");
}
if (issueId.length() == 0) {
throw new IllegalArgumentException("Issue id cannot be empty");
}
// POST /repos/:owner/:repo/issues/:number/labels
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id)
.append(SEGMENT_ISSUES)
.append('/').append(issueId)
.append(SEGMENT_LABELS);
return client.post(uri.toString(), labels, new TypeToken<List<Label>>() {
}.getType());
}
示例3: editLabel
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
/**
* @param repository
* @param label label with edited fields
* @param name name of label to edit
* @return
* @throws IOException
*/
public Label editLabel(IRepositoryIdProvider repository, Label label, String name)
throws IOException {
String repoId = getId(repository);
if (label == null) {
throw new IllegalArgumentException("Label cannot be null"); //$NON-NLS-1$
}
if (name == null) {
throw new IllegalArgumentException("Label name cannot be null"); //$NON-NLS-1$
}
if (name.length() == 0) {
throw new IllegalArgumentException("Label name cannot be empty"); //$NON-NLS-1$
}
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(repoId)
.append(SEGMENT_LABELS)
.append('/').append(name);
return client.post(uri.toString(), label, Label.class);
}
示例4: turboIssueTest
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
@Test
public void turboIssueTest() {
Issue issue = new Issue();
issue.setNumber(1);
issue.setUser(new User().setLogin("test_user"));
issue.setCreatedAt(new Date());
issue.setUpdatedAt(new Date());
issue.setState("open");
ArrayList<Label> labels = new ArrayList<>();
labels.add(new Label().setName("test label"));
issue.setLabels(labels);
TurboIssue turboIssue = new TurboIssue("dummy/dummy", issue);
assertEquals(1, turboIssue.getId());
assertEquals("test_user", turboIssue.getCreator());
assertEquals(true, turboIssue.isOpen());
assertEquals("test label", turboIssue.getLabels().get(0));
}
示例5: updateLabels
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
/**
* Update label views with values from given label models
*
* @param labels
* @param viewIndex
*/
protected void updateLabels(final List<Label> labels, final int viewIndex) {
if (labels != null && !labels.isEmpty()) {
int size = Math.min(labels.size(), MAX_LABELS);
for (int i = 0; i < size; i++) {
String color = labels.get(i).getColor();
if (!TextUtils.isEmpty(color)) {
View view = view(viewIndex + i);
view.setBackgroundColor(Color.parseColor('#' + color));
ViewUtils.setGone(view, false);
} else
setGone(viewIndex + i, true);
}
for (int i = size; i < MAX_LABELS; i++)
setGone(viewIndex + i, true);
} else
for (int i = 0; i < MAX_LABELS; i++)
setGone(viewIndex + i, true);
}
示例6: show
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
/**
* Show dialog with given labels selected
*
* @param selectedLabels
*/
public void show(Collection<Label> selectedLabels) {
if (labels == null) {
load(selectedLabels);
return;
}
final ArrayList<Label> names = new ArrayList<Label>(labels.values());
final boolean[] checked = new boolean[names.size()];
if (selectedLabels != null && !selectedLabels.isEmpty()) {
Set<String> selectedNames = new HashSet<String>();
for (Label label : selectedLabels)
selectedNames.add(label.getName());
for (int i = 0; i < checked.length; i++)
if (selectedNames.contains(names.get(i).getName()))
checked[i] = true;
}
LabelsDialogFragment.show(activity, requestCode,
activity.getString(string.select_labels), null, names, checked);
}
示例7: saveLabel
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
public Label saveLabel(Repository repository, Label label,String oldLabelName){
try {
//System.out.println(label.getName());
//label.setName(label.getName().replace(" ", "%x62"));
//System.out.println(label.getName());
if(oldLabelName.compareTo(label.getName()) == 0){
return labelService.editLabel(repository, label);
}else{
labelService.deleteLabel(repository, oldLabelName);
return labelService.createLabel(repository, label);
}
} catch (IOException e) {
mainApp.writeNotification("Failed saving label.\n"+e.getMessage());
return null;
}
}
示例8: makeOrGetReviewRequestLabel
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
private Label makeOrGetReviewRequestLabel(GitHubClient client, Repo repo) {
Label reviewRequestLabel = new Label().setColor("009800").setName("Review Request");
LabelService labelService = new LabelService(client);
try {
reviewRequestLabel = labelService.getLabel(repo.repoOwner, repo.repoName, "Review Request");
} catch(IOException e) {
System.out.println("Review Request Label not found. Going to create it");
try {
reviewRequestLabel = labelService.createLabel(repo.repoOwner, repo.repoName, reviewRequestLabel);
} catch (IOException e1) {
e1.printStackTrace(); //this is a bigger problem
}
}
return reviewRequestLabel;
}
示例9: createReviewRequestIssue
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
private void createReviewRequestIssue(Label reviewRequestLabel, Review review, IssueService issueService, UserService userService) throws IOException {
Issue issue = new Issue();
issue.setTitle("Reviewer - " + review.reviewer.login);
List<Label> labels = new ArrayList<>();
labels.add(reviewRequestLabel);
issue.setLabels(labels);
issue.setAssignee(userService.getUser(review.reviewer.login));
String downloadLink = "https://github.com/" + review.repo.repoOwner + '/' + review.repo.repoName + "/raw/master/" + review.pathToPaperInRepo;
issue.setBody("@" + review.reviewer.login + " has been requested to review this paper by @"+review.requester.login+".\n" +
"Click [here](" + downloadLink + ") to download the paper\n" +
"Click [here](" + review.linkToReviewPaper + ") to upload your review.");
issueService.createIssue(review.repo.repoOwner, review.repo.repoName, issue);
}
示例10: run
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
@Override
public void run() {
try {
GitHubClient client = new GitHubClient();
client.setOAuth2Token(accessToken);
DBAbstraction database = DatabaseFactory.getDatabase();
UserService userService = new UserService(client);
User reviewer = userService.getUser();
List<Label> customLabels = createCustomLabels(client);
createIssues(client, customLabels);
String closeComment = "@" + reviewer.getLogin() + " has reviewed this paper.";
closeReviewIssue(client, repo, reviewer.getLogin(), closeComment);
database.removeReviewFromDatastore(reviewer.getLogin(), repo);
} catch(IOException e) {
e.printStackTrace();
System.err.println("Error processing Pdf.");
}
}
示例11: createCustomLabels
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
private List<Label> createCustomLabels(GitHubClient client) {
List<Label> labels = new ArrayList<>();
LabelService labelService = new LabelService(client);
for (String customLabel : customLabelStrings) {
Label newLabel = new Label().setColor(randomColor()).setName(customLabel);
try {
Label alreadyExistingLabel = labelService.getLabel(repo.repoOwner, repo.repoName, customLabel);
labels.add(alreadyExistingLabel);
} catch(IOException e) {
System.out.println("new label " +customLabel + " not found. Going to create it");
try {
newLabel = labelService.createLabel(repo.repoOwner, repo.repoName, newLabel);
} catch (IOException e1) {
e1.printStackTrace(); //this is a bigger problem
}
labels.add(newLabel);
}
}
return labels;
}
示例12: setLabels
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
private List<Label> setLabels(String id, String issueId, List<Label> labels)
throws IOException {
if (issueId == null)
throw new IllegalArgumentException("Issue id cannot be null"); //$NON-NLS-1$
if (issueId.length() == 0)
throw new IllegalArgumentException("Issue id cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_ISSUES);
uri.append('/').append(issueId);
uri.append(SEGMENT_LABELS);
return client.put(uri.toString(), labels, new TypeToken<List<Label>>() {
}.getType());
}
示例13: editLabel
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
/**
* Edit the given label in the given repository
*
* @param repository
* @param label
* @return edited label
* @throws IOException
*/
public Label editLabel(IRepositoryIdProvider repository, Label label)
throws IOException {
String repoId = getId(repository);
if (label == null)
throw new IllegalArgumentException("Label cannot be null"); //$NON-NLS-1$
String name = label.getName();
if (name == null)
throw new IllegalArgumentException("Label name cannot be null"); //$NON-NLS-1$
if (name.length() == 0)
throw new IllegalArgumentException("Label name cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(repoId);
uri.append(SEGMENT_LABELS);
uri.append('/').append(name);
return client.post(uri.toString(), label, Label.class);
}
示例14: getLabels
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
public PageIterator<Label> getLabels(final IRepositoryIdProvider repository, final int issueNumber) {
String repoId = this.getId(repository);
StringBuilder uri = new StringBuilder("/repos");
uri.append('/').append(repoId);
uri.append("/issues");
uri.append('/').append(issueNumber);
uri.append("/labels");
PagedRequest<Label> request = this.createPagedRequest();
request.setUri(uri);
request.setType((new TypeToken<List<Label>>() {}).getType());
return this.createPageIterator(request);
}
示例15: setLabels
import org.eclipse.egit.github.core.Label; //导入依赖的package包/类
public List<Label> setLabels(final IRepositoryIdProvider repository,
final int issueNumber,
final String...labels) throws IOException {
String repoId = this.getId(repository);
StringBuilder uri = new StringBuilder("/repos");
uri.append('/').append(repoId);
uri.append("/issues");
uri.append('/').append(issueNumber);
uri.append("/labels");
List<String> params = Arrays.asList(labels);
return getClient().put(uri.toString(), params, (new TypeToken<List<Label>>(){}).getType());
}