From 74ce5cb522da0adf2233c3dbb3ccd69f73edd33c Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 12 Mar 2015 19:11:55 +0300 Subject: [PATCH 01/11] github: fix message dialog title capitalisation --- .../github/GithubCreatePullRequestWorker.java | 10 ++++++---- .../jetbrains/plugins/github/GithubShareAction.java | 12 ++++++------ .../plugins/github/tasks/GithubRepositoryEditor.java | 2 +- .../plugins/github/ui/GithubSettingsPanel.java | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestWorker.java b/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestWorker.java index 8a818cac09b7..b65e7f204ef1 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestWorker.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestWorker.java @@ -503,13 +503,15 @@ public class GithubCreatePullRequestWorker { String targetBranchName = "'" + fork.getRemoteName() + "/" + branch.getRemoteName() + "'"; if (info.getInfo().getBranchToHeadCommits(myGitRepository).isEmpty()) { return GithubNotifications - .showYesNoDialog(myProject, "Do you want to proceed anyway?", - "Empty pull request: the branch " + localBranchName + " is fully merged to the branch " + targetBranchName); + .showYesNoDialog(myProject, "Empty Pull Request", + "The branch " + localBranchName + " is fully merged to the branch " + targetBranchName + '\n' + + "Do you want to proceed anyway?"); } if (!info.getInfo().getHeadToBranchCommits(myGitRepository).isEmpty()) { return GithubNotifications - .showYesNoDialog(myProject, "Do you want to proceed anyway?", - "The branch " + targetBranchName + " is not fully merged to the branch " + localBranchName); + .showYesNoDialog(myProject, "Target Branch Is Not Fully Merged", + "The branch " + targetBranchName + " is not fully merged to the branch " + localBranchName + '\n' + + "Do you want to proceed anyway?"); } return true; diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index 537a580775c8..5a369c01ca41 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -210,7 +210,7 @@ public class GithubShareAction extends DumbAwareAction { final GithubFullPath path = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(remote); if (path == null) { return GithubNotifications.showYesNoDialog(project, - "Project is already on GitHub", + "Project Is Already on GitHub", "Can't connect to repository from configured remote. You could want to check .git config.\n" + "Do you want to proceed anyway?"); } @@ -231,22 +231,22 @@ public class GithubShareAction extends DumbAwareAction { }); } }); - GithubNotifications.showInfoURL(project, "Project is already on GitHub", "GitHub", repo.getHtmlUrl()); + GithubNotifications.showInfoURL(project, "Project Is Already on GitHub", "GitHub", repo.getHtmlUrl()); return false; } catch (GithubStatusCodeException e) { if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { return GithubNotifications.showYesNoDialog(project, - "Project is already on GitHub", + "Project Is Already on GitHub", "Can't connect to repository from configured remote. You could want to check .git config.\n" + "Do you want to proceed anyway?"); } - GithubNotifications.showErrorDialog(project, "Failed to connect to GitHub", e); + GithubNotifications.showErrorDialog(project, "Failed to Connect to GitHub", e); return false; } catch (IOException e) { - GithubNotifications.showErrorDialog(project, "Failed to connect to GitHub", e); + GithubNotifications.showErrorDialog(project, "Failed to Connect to GitHub", e); return false; } } @@ -278,7 +278,7 @@ public class GithubShareAction extends DumbAwareAction { }); } catch (IOException e) { - GithubNotifications.showErrorDialog(project, "Failed to connect to GitHub", e); + GithubNotifications.showErrorDialog(project, "Failed to Connect to GitHub", e); return null; } } diff --git a/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java b/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java index e3e8daabb56a..d826763e1667 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java +++ b/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java @@ -139,7 +139,7 @@ public class GithubRepositoryEditor extends BaseRepositoryEditor Date: Thu, 12 Mar 2015 19:08:04 +0300 Subject: [PATCH 02/11] IDEA-124356 github: allow to share project even with valid configured remote --- .../jetbrains/plugins/github/GithubShareAction.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index 5a369c01ca41..e3d077d94416 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -15,6 +15,7 @@ */ package org.jetbrains.plugins.github; +import com.intellij.ide.BrowserUtil; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ServiceManager; @@ -23,6 +24,7 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Ref; @@ -231,7 +233,15 @@ public class GithubShareAction extends DumbAwareAction { }); } }); - GithubNotifications.showInfoURL(project, "Project Is Already on GitHub", "GitHub", repo.getHtmlUrl()); + int result = Messages.showDialog(project, + "Successfully connected to " + repo.getHtmlUrl() + ".\n" + + "Do you want to proceed anyway?", + "Project Is Already on GitHub", + new String[]{"Continue", "Open in Browser", Messages.CANCEL_BUTTON}, 2, Messages.getQuestionIcon()); + if (result == 0) return true; + if (result == 1) { + BrowserUtil.browse(repo.getHtmlUrl()); + } return false; } catch (GithubStatusCodeException e) { From 167e9a4d2b0b47c67e405f072a520d0f0486307c Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 12 Mar 2015 20:14:37 +0300 Subject: [PATCH 03/11] IDEA-84865 github: allow to clone/share repos using ssh remote --- .../extensions/GithubCheckoutProvider.java | 3 ++- .../plugins/github/ui/GithubSettingsPanel.form | 16 ++++++++++++---- .../plugins/github/ui/GithubSettingsPanel.java | 11 ++++++++--- .../plugins/github/util/GithubSettings.java | 9 +++++++++ .../plugins/github/util/GithubUrlUtil.java | 7 ++++++- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java b/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java index 1364e4ad7c66..260a7b36e88b 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java +++ b/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java @@ -33,6 +33,7 @@ import org.jetbrains.plugins.github.api.GithubConnection; import org.jetbrains.plugins.github.api.GithubRepo; import org.jetbrains.plugins.github.util.GithubAuthDataHolder; import org.jetbrains.plugins.github.util.GithubNotifications; +import org.jetbrains.plugins.github.util.GithubUrlUtil; import org.jetbrains.plugins.github.util.GithubUtil; import java.io.File; @@ -88,7 +89,7 @@ public class GithubCheckoutProvider implements CheckoutProvider { // Add predefined repositories to history dialog.prependToHistory("-----------------------------------------------"); for (int i = availableRepos.size() - 1; i >= 0; i--) { - dialog.prependToHistory(availableRepos.get(i).getCloneUrl()); + dialog.prependToHistory(GithubUrlUtil.getCloneUrl(availableRepos.get(i).getFullPath())); } if (!dialog.showAndGet()) { return; diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form index a31ae1af9432..bbb624cbf825 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.form @@ -1,6 +1,6 @@
- + @@ -28,7 +28,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -204,7 +204,15 @@ - + + + + + + + + + diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java index 66cd69ef615f..7b9d1368c487 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java @@ -25,6 +25,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.HyperlinkAdapter; +import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; import com.intellij.util.ThrowableConvertor; import org.jetbrains.annotations.NotNull; @@ -33,7 +34,6 @@ import org.jetbrains.plugins.github.api.GithubApiUtil; import org.jetbrains.plugins.github.api.GithubConnection; import org.jetbrains.plugins.github.api.GithubUser; import org.jetbrains.plugins.github.exceptions.GithubAuthenticationException; -import org.jetbrains.plugins.github.exceptions.GithubOperationCanceledException; import org.jetbrains.plugins.github.util.*; import javax.swing.*; @@ -71,6 +71,7 @@ public class GithubSettingsPanel { private JBLabel myAuthTypeLabel; private JSpinner myTimeoutSpinner; private JButton myCreateTokenButton; + private JBCheckBox myCloneUsingSshCheckBox; private boolean myCredentialsModified; @@ -286,6 +287,7 @@ public class GithubSettingsPanel { setPassword(mySettings.isAuthConfigured() ? DEFAULT_PASSWORD_TEXT : ""); setAuthType(mySettings.getAuthType()); setConnectionTimeout(mySettings.getConnectionTimeout()); + myCloneUsingSshCheckBox.setSelected(mySettings.isCloneGitUsingSsh()); resetCredentialsModification(); } @@ -294,12 +296,15 @@ public class GithubSettingsPanel { mySettings.setAuthData(getAuthData(), true); } mySettings.setConnectionTimeout(getConnectionTimeout()); + mySettings.setCloneGitUsingSsh(myCloneUsingSshCheckBox.isSelected()); resetCredentialsModification(); } public boolean isModified() { - return myCredentialsModified || !Comparing.equal(mySettings.getHost(), getHost()) || - !Comparing.equal(mySettings.getConnectionTimeout(), getConnectionTimeout()); + return myCredentialsModified || + !Comparing.equal(mySettings.getHost(), getHost()) || + !Comparing.equal(mySettings.getConnectionTimeout(), getConnectionTimeout()) || + !Comparing.equal(mySettings.isCloneGitUsingSsh(), myCloneUsingSshCheckBox.isSelected()); } public void resetCredentialsModification() { diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java index 7e98d47d8220..e86ffab49e4d 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java @@ -62,6 +62,7 @@ public class GithubSettings implements PersistentStateComponent Date: Thu, 12 Mar 2015 20:38:13 +0300 Subject: [PATCH 04/11] github: allow to specify remote while sharing project on github --- .../plugins/github/GithubShareAction.java | 22 +++++++++------- .../plugins/github/ui/GithubShareDialog.java | 17 ++++++++++-- .../plugins/github/ui/GithubSharePanel.form | 26 +++++++++++++++---- .../plugins/github/ui/GithubSharePanel.java | 18 ++++++++++--- 4 files changed, 64 insertions(+), 19 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index e3d077d94416..dd19041da102 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -35,6 +35,7 @@ import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vcs.changes.ui.SelectFilesDialog; import com.intellij.openapi.vcs.ui.CommitMessage; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.Function; import com.intellij.util.ThrowableConvertor; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; @@ -46,6 +47,7 @@ import git4idea.actions.BasicAction; import git4idea.actions.GitInit; import git4idea.commands.*; import git4idea.i18n.GitBundle; +import git4idea.repo.GitRemote; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; import git4idea.util.GitFileUtils; @@ -64,9 +66,7 @@ import org.jetbrains.plugins.github.util.GithubUtil; import javax.swing.*; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.*; import static org.jetbrains.plugins.github.util.GithubUtil.setVisibleEnabled; @@ -121,13 +121,19 @@ public class GithubShareAction extends DumbAwareAction { final GithubAuthDataHolder authHolder = GithubAuthDataHolder.createFromSettings(); // check for existing git repo - boolean externalRemoteDetected = false; + Set existingRemotes = Collections.emptySet(); if (gitDetected) { final String githubRemote = GithubUtil.findGithubRemoteUrl(gitRepository); if (githubRemote != null) { if (!checkExistingRemote(project, authHolder, githubRemote)) return; } - externalRemoteDetected = !gitRepository.getRemotes().isEmpty(); + + existingRemotes = ContainerUtil.map2Set(gitRepository.getRemotes(), new Function() { + @Override + public String fun(GitRemote remote) { + return remote.getName(); + } + }); } // get available GitHub repos with modal progress @@ -138,7 +144,7 @@ public class GithubShareAction extends DumbAwareAction { // Show dialog (window) final GithubShareDialog shareDialog = - new GithubShareDialog(project, githubInfo.getRepositoryNames(), githubInfo.getUser().canCreatePrivateRepo()); + new GithubShareDialog(project, githubInfo.getRepositoryNames(), existingRemotes, githubInfo.getUser().canCreatePrivateRepo()); DialogManager.show(shareDialog); if (!shareDialog.isOK()) { return; @@ -146,9 +152,8 @@ public class GithubShareAction extends DumbAwareAction { final boolean isPrivate = shareDialog.isPrivate(); final String name = shareDialog.getRepositoryName(); final String description = shareDialog.getDescription(); + final String remoteName = shareDialog.getRemoteName(); - // finish the job in background - final boolean finalExternalRemoteDetected = externalRemoteDetected; new Task.Backgroundable(project, "Sharing project on GitHub...") { @Override public void run(@NotNull ProgressIndicator indicator) { @@ -180,7 +185,6 @@ public class GithubShareAction extends DumbAwareAction { } final String remoteUrl = GithubUrlUtil.getCloneUrl(githubInfo.getUser().getLogin(), name); - final String remoteName = finalExternalRemoteDetected ? "github" : "origin"; //git remote add origin git@github.com:login/name.git LOG.info("Adding GitHub as a remote host"); diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java index 3b464b2828ac..a6a537faf74f 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubShareDialog.java @@ -18,15 +18,18 @@ public class GithubShareDialog extends DialogWrapper { private static final Pattern GITHUB_REPO_PATTERN = Pattern.compile("[a-zA-Z0-9_.-]+"); private final GithubSharePanel myGithubSharePanel; private final Set myAvailableNames; + private final Set myAvailableRemotes; - public GithubShareDialog(final Project project, final Set availableNames, final boolean privateRepoAllowed) { + public GithubShareDialog(Project project, Set availableNames, Set availableRemotes, boolean privateRepoAllowed) { super(project); myAvailableNames = availableNames; + myAvailableRemotes = availableRemotes; myGithubSharePanel = new GithubSharePanel(this); init(); setTitle("Share Project On GitHub"); setOKButtonText("Share"); myGithubSharePanel.setRepositoryName(project.getName()); + myGithubSharePanel.setRemoteName(availableRemotes.isEmpty() ? "origin" : "github"); myGithubSharePanel.setPrivateRepoAvailable(privateRepoAllowed); init(); updateOkButton(); @@ -53,7 +56,8 @@ public class GithubShareDialog extends DialogWrapper { } public void updateOkButton() { - final String repositoryName = getRepositoryName(); + String repositoryName = getRepositoryName(); + String remoteName = getRemoteName(); if (StringUtil.isEmpty(repositoryName)){ setErrorText("No repository name selected"); setOKActionEnabled(false); @@ -64,6 +68,11 @@ public class GithubShareDialog extends DialogWrapper { setOKActionEnabled(false); return; } + if (myAvailableRemotes.contains(remoteName)) { + setErrorText("Remote with selected name already exists"); + setOKActionEnabled(false); + return; + } if (!GITHUB_REPO_PATTERN.matcher(repositoryName).matches()){ setErrorText("Invalid repository name. Name should consist of letters, numbers, dashes, dots and underscores"); setOKActionEnabled(false); @@ -85,6 +94,10 @@ public class GithubShareDialog extends DialogWrapper { return myGithubSharePanel.getDescription(); } + public String getRemoteName() { + return myGithubSharePanel.getRemoteName(); + } + @TestOnly public void testSetRepositoryName(@NotNull String name) { myGithubSharePanel.setRepositoryName(name); diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.form b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.form index 31fa28e4c1c9..f8493892389d 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.form +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.form @@ -1,9 +1,9 @@ - + - + @@ -26,7 +26,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -57,9 +57,25 @@ - + + + + + + + + + + + + + + + + + diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.java index 647a811320b8..18eb66b1292a 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.java +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSharePanel.java @@ -14,17 +14,21 @@ public class GithubSharePanel { private JTextField myRepositoryTextField; private JCheckBox myPrivateCheckBox; private JTextArea myDescriptionTextArea; + private JTextField myRemoteTextField; private final GithubShareDialog myGithubShareDialog; public GithubSharePanel(final GithubShareDialog githubShareDialog) { myGithubShareDialog = githubShareDialog; - myRepositoryTextField.getDocument().addDocumentListener(new DocumentAdapter() { + myPrivateCheckBox.setSelected(false); + + DocumentAdapter changeListener = new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { myGithubShareDialog.updateOkButton(); } - }); - myPrivateCheckBox.setSelected(false); + }; + myRepositoryTextField.getDocument().addDocumentListener(changeListener); + myRemoteTextField.getDocument().addDocumentListener(changeListener); } public JPanel getPanel() { @@ -43,6 +47,14 @@ public class GithubSharePanel { myRepositoryTextField.setText(name); } + public String getRemoteName() { + return myRemoteTextField.getText().trim(); + } + + public void setRemoteName(final String name) { + myRemoteTextField.setText(name); + } + public boolean isPrivate() { return myPrivateCheckBox.isSelected(); } From 52e8a43dc0e023e7be1b5d652aecdc65ae127da9 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 13 Mar 2015 17:14:55 +0300 Subject: [PATCH 05/11] IDEA-137526 Remote debugging not working - fixed no notification in some cases --- .../debugger/engine/DebugProcessImpl.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index 20f0cb122cad..24224f93c530 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -26,10 +26,7 @@ import com.intellij.debugger.engine.events.SuspendContextCommandImpl; import com.intellij.debugger.engine.jdi.ThreadReferenceProxy; import com.intellij.debugger.engine.requests.MethodReturnValueWatcher; import com.intellij.debugger.engine.requests.RequestManagerImpl; -import com.intellij.debugger.impl.DebuggerContextImpl; -import com.intellij.debugger.impl.DebuggerSession; -import com.intellij.debugger.impl.DebuggerUtilsEx; -import com.intellij.debugger.impl.PrioritizedTask; +import com.intellij.debugger.impl.*; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.jdi.ThreadReferenceProxyImpl; import com.intellij.debugger.jdi.VirtualMachineProxyImpl; @@ -89,6 +86,7 @@ import javax.swing.*; import java.io.IOException; import java.net.UnknownHostException; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; public abstract class DebugProcessImpl extends UserDataHolderBase implements DebugProcess { @@ -1852,7 +1850,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb final Semaphore semaphore = new Semaphore(); semaphore.down(); - final Ref connectorIsReady = Ref.create(false); + final AtomicBoolean connectorIsReady = new AtomicBoolean(false); myDebugProcessDispatcher.addListener(new DebugProcessAdapter() { @Override public void connectorIsReady() { @@ -1890,17 +1888,17 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb } else { fail(); - if (myExecutionResult != null || !connectorIsReady.get()) { - // propagate exception only in case we succeeded to obtain execution result, - // otherwise if the error is induced by the fact that there is nothing to debug, and there is no need to show - // this problem to the user - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { + DebuggerInvocationUtil.swingInvokeLater(myProject, new Runnable() { + @Override + public void run() { + // propagate exception only in case we succeeded to obtain execution result, + // otherwise if the error is induced by the fact that there is nothing to debug, and there is no need to show + // this problem to the user + if (myExecutionResult != null || !connectorIsReady.get()) { ExecutionUtil.handleExecutionError(myProject, ToolWindowId.DEBUG, sessionName, e); } - }); - } + } + }); break; } } From 532563d434532c6dc7bb97c3b4dae1616b8e8c10 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 13 Mar 2015 17:35:24 +0300 Subject: [PATCH 06/11] EA-66219 - NA: MasterPasswordDialog.askPassword --- .../src/git4idea/commands/GitHttpGuiAuthenticator.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java index c5931f98df10..cf6b81c36cd6 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java +++ b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java @@ -15,6 +15,7 @@ */ package git4idea.commands; +import com.intellij.ide.passwordSafe.MasterPasswordUnavailableException; import com.intellij.ide.passwordSafe.PasswordSafe; import com.intellij.ide.passwordSafe.PasswordSafeException; import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl; @@ -169,6 +170,8 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { passwordSafe.getMasterKeyProvider().storePassword(myProject, PASS_REQUESTER, myPasswordKey, myPassword); } } + catch (MasterPasswordUnavailableException ignored) { + } catch (PasswordSafeException e) { LOG.error("Couldn't remember password for " + myPasswordKey, e); } From d03fa10c14a7aa4d51447ae031f6ac367ae87029 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 13 Mar 2015 17:35:47 +0300 Subject: [PATCH 07/11] cleanup --- .../masterKey/EnterPasswordComponent.java | 3 +- .../providers/masterKey/MasterKeyUtils.java | 57 ------------------- .../masterKey/MasterPasswordDialog.java | 2 +- .../masterKey/PasswordComponentBase.java | 6 ++ 4 files changed, 8 insertions(+), 60 deletions(-) delete mode 100644 platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyUtils.java diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java index 304b31e3bee1..d5f164c5108a 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java @@ -15,7 +15,6 @@ */ package com.intellij.ide.passwordSafe.impl.providers.masterKey; -import com.intellij.ide.TypePresentationService; import com.intellij.ide.passwordSafe.HelpID; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.util.ui.UIUtil; @@ -28,7 +27,7 @@ public class EnterPasswordComponent extends PasswordComponentBase { public EnterPasswordComponent(@NotNull MasterKeyPasswordSafe safe, @NotNull Class requestor) { super(safe, "Enter"); - String requestorName = TypePresentationService.getDefaultTypeName(requestor); // requestor.getSimpleName(); + String requestorName = getRequestorTitle(requestor); myPromptLabel.setText("
Master password is required to unlock the password database.
" + "The password database will be unlocked during this session
" + "for all subsystems.
" + diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyUtils.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyUtils.java deleted file mode 100644 index bd3203a4bc8f..000000000000 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.ide.passwordSafe.impl.providers.masterKey; - -import com.intellij.ui.DocumentAdapter; -import com.intellij.util.Processor; - -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import java.util.Arrays; - -/** - * Utilities for master key provider - */ -class MasterKeyUtils { - /** - * The private constructor for utility class - */ - private MasterKeyUtils() { - } - - /** - * Match passwords - * - * @param passwordField1 the first password field - * @param passwordField2 the second password field - * @param setError the callback used to set or to clear an error - */ - static void matchPasswords(final JPasswordField passwordField1, final JPasswordField passwordField2, final Processor setError) { - DocumentAdapter l = new DocumentAdapter() { - @Override - protected void textChanged(DocumentEvent e) { - if (Arrays.equals(passwordField1.getPassword(), passwordField2.getPassword())) { - setError.process(null); - } - else { - setError.process("The new password and confirm passwords do not match."); - } - } - }; - passwordField1.getDocument().addDocumentListener(l); - passwordField2.getDocument().addDocumentListener(l); - } -} diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java index f81d328c7049..f9d16b0bc63c 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterPasswordDialog.java @@ -63,7 +63,7 @@ public class MasterPasswordDialog extends DialogWrapper { } if (!enterMasterPasswordDialog(project, safe, requestor).showAndGet()) { - throw new MasterPasswordUnavailableException("Cancelled by user"); + throw new MasterPasswordUnavailableException(PasswordComponentBase.getRequestorTitle(requestor) + ": Cancelled by user"); } } diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/PasswordComponentBase.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/PasswordComponentBase.java index 2307fa9464f1..453fd0f133ac 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/PasswordComponentBase.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/PasswordComponentBase.java @@ -16,6 +16,7 @@ package com.intellij.ide.passwordSafe.impl.providers.masterKey; import com.intellij.icons.AllIcons; +import com.intellij.ide.TypePresentationService; import com.intellij.openapi.ui.ValidationInfo; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -100,4 +101,9 @@ public abstract class PasswordComponentBase { } return null; } + + @NotNull + public static String getRequestorTitle(@NotNull Class requestor) { + return TypePresentationService.getDefaultTypeName(requestor); + } } From 732a7f6c631964142bcfb98ca04e9841d1891223 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 13 Mar 2015 15:19:28 +0100 Subject: [PATCH 08/11] CreatePropertyFromUsageFix live template: store type pointers (EA-66318 - PIEAE: PsiUtilCore.ensureValid) --- .../quickfix/CreatePropertyFromUsageFix.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java index ac2e35b9b776..72b608bfce94 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreatePropertyFromUsageFix.java @@ -37,7 +37,9 @@ import com.intellij.psi.codeStyle.VariableKind; import com.intellij.psi.util.PropertyUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; +import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -120,12 +122,17 @@ public class CreatePropertyFromUsageFix extends CreateFromUsageBaseFix implement private final String myDefaultFieldName; private final PsiField myField; private final PsiClass myClass; - private final PsiType[] myExpectedTypes; + private final List myExpectedTypes; - public FieldExpression(PsiField field, PsiClass aClass, PsiType[] expectedTypes) { + public FieldExpression(final PsiField field, PsiClass aClass, PsiType[] expectedTypes) { myField = field; myClass = aClass; - myExpectedTypes = expectedTypes; + myExpectedTypes = ContainerUtil.map(expectedTypes, new Function() { + @Override + public SmartTypePointer fun(PsiType type) { + return SmartTypePointerManager.getInstance(field.getProject()).createSmartTypePointer(type); + } + }); myDefaultFieldName = field.getName(); } @@ -143,12 +150,11 @@ public class CreatePropertyFromUsageFix extends CreateFromUsageBaseFix implement public LookupElement[] calculateLookupItems(ExpressionContext context) { Set set = new LinkedHashSet(); set.add(JavaLookupElementBuilder.forField(myField).withTypeText(myField.getType().getPresentableText())); - PsiField[] fields = myClass.getFields(); - for (PsiField otherField : fields) { + for (PsiField otherField : myClass.getFields()) { if (!myDefaultFieldName.equals(otherField.getName())) { PsiType otherType = otherField.getType(); - for (PsiType type : myExpectedTypes) { - if (type.equals(otherType)) { + for (SmartTypePointer pointer : myExpectedTypes) { + if (otherType.equals(pointer.getType())) { set.add(JavaLookupElementBuilder.forField(otherField).withTypeText(otherType.getPresentableText())); } } From 3d365633e67bfdfae46b669a9ed1d267da8a6c18 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 13 Mar 2015 15:23:23 +0100 Subject: [PATCH 09/11] start testng tests in smart mode (EA-66189 - INRE) --- .../testng/configuration/SearchingForTestsTask.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java index 3e532757c54a..538a4bb005b6 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java @@ -123,10 +123,15 @@ public class SearchingForTestsTask extends Task.Backgroundable { @Override public void onSuccess() { - writeTempFile(); - finish(); + DumbService.getInstance(myProject).runWhenSmart(new Runnable() { + @Override + public void run() { + writeTempFile(); + finish(); - if (!Registry.is("testng_sm_runner")) myClient.startListening(myConfig); + if (!Registry.is("testng_sm_runner")) myClient.startListening(myConfig); + } + }); } @Override From c8bc2faaba1b907d999403952d11d6a7ce611728 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 13 Mar 2015 15:37:17 +0100 Subject: [PATCH 10/11] no GradleUrlProvider class search in dumb mode (EA-66160 - INRE) --- .../gradle/execution/test/runner/GradleUrlProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/GradleUrlProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/GradleUrlProvider.java index 1d073f9ab6df..3bf502b08c6e 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/GradleUrlProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/GradleUrlProvider.java @@ -17,13 +17,13 @@ package org.jetbrains.plugins.gradle.execution.test.runner; import com.intellij.execution.Location; import com.intellij.execution.PsiLocation; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMethod; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testIntegration.TestLocationProvider; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,6 +43,7 @@ public class GradleUrlProvider implements TestLocationProvider { @NotNull public List getLocation(@NotNull String protocolId, @NotNull String locationData, Project project) { if (!PROTOCOL_ID.equals(protocolId)) return Collections.emptyList(); + if (DumbService.isDumb(project)) return Collections.emptyList(); final String className = extractFullClassName(locationData); if (className == null) return Collections.emptyList(); From 0e8d393279f915a9c69a1726bb6c91ee4be1cdf0 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 13 Mar 2015 18:13:31 +0300 Subject: [PATCH 11/11] provide NTCredentials in case we encounter NTLM proxy #WEB-10266 fixed --- .../src/com/intellij/util/net/HttpConfigurable.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java index ae8f942dc15c..f0c915913b84 100644 --- a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java +++ b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java @@ -44,8 +44,10 @@ import gnu.trove.THashSet; import gnu.trove.TObjectObjectProcedure; import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; +import org.apache.http.auth.NTCredentials; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.config.AuthSchemes; import org.apache.http.client.config.RequestConfig; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -439,6 +441,8 @@ public class HttpConfigurable implements PersistentStateComponent