mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[github] Multiple accounts support for tasks settings
This commit is contained in:
@@ -12,17 +12,12 @@ import com.intellij.util.ui.FormBuilder;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.github.api.GithubApiUtil;
|
||||
import org.jetbrains.plugins.github.util.AuthLevel;
|
||||
import org.jetbrains.plugins.github.util.GithubAuthDataHolder;
|
||||
import org.jetbrains.plugins.github.util.GithubNotifications;
|
||||
import org.jetbrains.plugins.github.util.GithubUtil;
|
||||
import org.jetbrains.plugins.github.authentication.ui.GithubLoginDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Dennis.Ushakov
|
||||
@@ -106,12 +101,12 @@ public class GithubRepositoryEditor extends BaseRepositoryEditor<GithubRepositor
|
||||
installListener(myShowNotAssignedIssues);
|
||||
|
||||
return FormBuilder.createFormBuilder()
|
||||
.setAlignLabelOnRight(true)
|
||||
.addLabeledComponent(myHostLabel, myHostPanel)
|
||||
.addLabeledComponent(myRepositoryLabel, myRepoPanel)
|
||||
.addLabeledComponent(myTokenLabel, myTokenPanel)
|
||||
.addComponentToRightColumn(myShowNotAssignedIssues)
|
||||
.getPanel();
|
||||
.setAlignLabelOnRight(true)
|
||||
.addLabeledComponent(myHostLabel, myHostPanel)
|
||||
.addLabeledComponent(myRepositoryLabel, myRepoPanel)
|
||||
.addLabeledComponent(myTokenLabel, myTokenPanel)
|
||||
.addComponentToRightColumn(myShowNotAssignedIssues)
|
||||
.getPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,15 +119,16 @@ public class GithubRepositoryEditor extends BaseRepositoryEditor<GithubRepositor
|
||||
}
|
||||
|
||||
private void generateToken() {
|
||||
try {
|
||||
String token = GithubUtil.computeValueInModalIO(myProject, "Access to GitHub", indicator ->
|
||||
GithubUtil.runTask(myProject, GithubAuthDataHolder.createFromSettings(), indicator, AuthLevel.basicOnetime(getHost()), connection ->
|
||||
GithubApiUtil.getTasksToken(connection, getRepoAuthor(), getRepoName(), "IntelliJ tasks plugin")
|
||||
));
|
||||
myToken.setText(token);
|
||||
}
|
||||
catch (IOException e) {
|
||||
GithubNotifications.showErrorDialog(myProject, "Can't Get Access Token", e);
|
||||
GithubLoginDialog dialog = new GithubLoginDialog(myProject,
|
||||
(u, s) -> true,
|
||||
null,
|
||||
"Login To Github",
|
||||
getHost(),
|
||||
false,
|
||||
"",
|
||||
"IntelliJ tasks plugin");
|
||||
if (dialog.showAndGet()) {
|
||||
myToken.setText(dialog.getToken());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user