Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/intellij14.1' into intellij15
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
uwolfer committed Jun 13, 2021
2 parents bc0fc8c + fa2bb82 commit 0ea96c1
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 35 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ideaVersion=IC-15.0.5
ijPluginRepoChannel=
downloadIdeaSources=false
version=1.2.4-142
version=1.2.5-142
javaVersion=1.6
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.Messages;
import com.urswolfer.gerrit.client.rest.GerritAuthData;
import com.urswolfer.intellij.plugin.gerrit.ui.ShowProjectColumn;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.atomic.AtomicInteger;

/**
* Parts based on org.jetbrains.plugins.github.GithubSettings
*
Expand Down Expand Up @@ -80,7 +77,6 @@ public class GerritSettings implements PersistentStateComponent<Element>, Gerrit
private String cloneBaseUrl = "";

private Optional<String> preloadedPassword;
private AtomicInteger passwordDialogShowLimit = new AtomicInteger(3);

private Logger log;

Expand Down Expand Up @@ -163,33 +159,19 @@ public String getPassword() {
throw new IllegalStateException("Need to call #preloadPassword when password is required in background thread");
}
} else {
if (!preloadPassword()) {
return "";
}
preloadPassword();
}
return preloadedPassword.or("");
}

public boolean preloadPassword() {
public void preloadPassword() {
String password = null;
try {
password = PasswordSafe.getInstance().getPassword(null, GerritSettings.class, GERRIT_SETTINGS_PASSWORD_KEY);
} catch (PasswordSafeException e) {
log.info("Couldn't get password for key [" + GERRIT_SETTINGS_PASSWORD_KEY + "]", e);
}
if (Strings.isNullOrEmpty(password) && !Strings.isNullOrEmpty(getLogin())) {
if (passwordDialogShowLimit.decrementAndGet() <= 0) {
return false;
}
password = Messages.showPasswordDialog(
String.format("Password for accessing Gerrit required (Login: %s, URL: %s).", getLogin(), getHost()),
"Gerrit Password");
if (password == null) {
return false;
}
}
preloadedPassword = Optional.fromNullable(password);
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class GerritPushExtensionPanel extends JPanel {

private JCheckBox pushToGerritCheckBox;
private JCheckBox privateCheckBox;
private JCheckBox unmarkPrivateCheckBox;
private JCheckBox publishDraftCommentsCheckBox;
private JCheckBox wipCheckBox;
private JCheckBox draftChangeCheckBox;
Expand Down Expand Up @@ -155,55 +156,59 @@ private void createLayout() {
pushToGerritCheckBox = new JCheckBox("Push to Gerrit");
mainPanel.add(pushToGerritCheckBox);

indentedSettingPanel = new JPanel(new GridLayoutManager(11, 2));
indentedSettingPanel = new JPanel(new GridLayoutManager(12, 2));

privateCheckBox = new JCheckBox("Private (Gerrit 2.15+)");
privateCheckBox.setToolTipText("Push a private change or to turn a change private.");
indentedSettingPanel.add(privateCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));

unmarkPrivateCheckBox = new JCheckBox("Unmark Private (Gerrit 2.15+)");
unmarkPrivateCheckBox.setToolTipText("Unmark an existing change private.");
indentedSettingPanel.add(unmarkPrivateCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));

wipCheckBox = new JCheckBox("WIP (Work-In-Progress Changes) (Gerrit 2.15+)");
wipCheckBox.setToolTipText("Push a wip change or to turn a change to wip.");
indentedSettingPanel.add(wipCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));
indentedSettingPanel.add(wipCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));

publishDraftCommentsCheckBox = new JCheckBox("Publish Draft Comments (Gerrit 2.15+)");
publishDraftCommentsCheckBox.setToolTipText("If you have draft comments on the change(s) that are updated by the push, the publish-comments option will cause them to be published.");
indentedSettingPanel.add(publishDraftCommentsCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));
indentedSettingPanel.add(publishDraftCommentsCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));

draftChangeCheckBox = new JCheckBox("Draft-Change (Gerrit older than 2.15)");
draftChangeCheckBox.setToolTipText("Publish change as draft (reviewers cannot submit change).");
indentedSettingPanel.add(draftChangeCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));
indentedSettingPanel.add(draftChangeCheckBox, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));

submitChangeCheckBox = new JCheckBox("Submit Change");
submitChangeCheckBox.setToolTipText("Changes can be directly submitted on push. This is primarily useful for " +
"teams that don't want to do code review but want to use Gerrit’s submit strategies to handle " +
"contention on busy branches. Using submit creates a change and submits it immediately, if the caller " +
"has submit permission.");
indentedSettingPanel.add(submitChangeCheckBox, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));
indentedSettingPanel.add(submitChangeCheckBox, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null));

branchTextField = addTextField(
"Branch:",
"The push destination branch.",
6);
7);

topicTextField = addTextField(
"Topic:",
"A short topic associated with all of the changes in the same group, such as the local topic branch name.",
7);
8);

hashTagTextField = addTextField(
"Hashtag (Gerrit 2.15+):",
"Include a hashtag associated with all of the changes in the same group.",
8);
9);

reviewersTextField = addTextField(
"Reviewers (user names, comma separated):",
"Users which will be added as reviewers.",
9);
10);

ccTextField = addTextField(
"CC (user names, comma separated):",
"Users which will receive carbon copies of the notification message.",
10);
11);

final JPanel settingLayoutPanel = new JPanel();
settingLayoutPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
Expand Down Expand Up @@ -247,6 +252,7 @@ private void addChangeListener() {
ChangeActionListener gerritPushChangeListener = new ChangeActionListener();
pushToGerritCheckBox.addActionListener(gerritPushChangeListener);
privateCheckBox.addActionListener(gerritPushChangeListener);
unmarkPrivateCheckBox.addActionListener(gerritPushChangeListener);
wipCheckBox.addActionListener(gerritPushChangeListener);
publishDraftCommentsCheckBox.addActionListener(gerritPushChangeListener);
draftChangeCheckBox.addActionListener(gerritPushChangeListener);
Expand Down Expand Up @@ -276,6 +282,8 @@ private String getRef() {
List<String> gerritSpecs = Lists.newArrayList();
if (privateCheckBox.isSelected()) {
gerritSpecs.add("private");
} else if (unmarkPrivateCheckBox.isSelected()) {
gerritSpecs.add("remove-private");
}
if (wipCheckBox.isSelected()) {
gerritSpecs.add("wip");
Expand All @@ -302,6 +310,11 @@ private String getRef() {
return ref;
}

private void handlePrivateCheckBoxExclusive() {
privateCheckBox.setEnabled(!unmarkPrivateCheckBox.isSelected());
unmarkPrivateCheckBox.setEnabled(!privateCheckBox.isSelected());
}

private void handleCommaSeparatedUserNames(List<String> gerritSpecs, JTextField textField, String option) {
Iterable<String> items = COMMA_SPLITTER.split(textField.getText());
for (String item : items) {
Expand All @@ -323,6 +336,9 @@ private void updateDestinationBranch() {

private void setSettingsEnabled(boolean enabled) {
UIUtil.setEnabled(indentedSettingPanel, enabled, true);
if (enabled) {
handlePrivateCheckBoxExclusive();
}
}

/**
Expand All @@ -332,6 +348,7 @@ private class ChangeActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
updateDestinationBranch();
handlePrivateCheckBoxExclusive();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,8 @@ public void run() {
}
}
};
if (gerritSettings.preloadPassword()) {
backgroundTask.queue();
}
gerritSettings.preloadPassword();
backgroundTask.queue();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ public void actionPerformed(ActionEvent e) {
return;
}
try {
GerritAuthData.Basic gerritAuthData = new GerritAuthData.Basic(host, getLogin(), password);
GerritAuthData.Basic gerritAuthData = new GerritAuthData.Basic(host, getLogin(), password) {
@Override
public boolean isLoginAndPasswordAvailable() {
return !Strings.isNullOrEmpty(getLogin());
}
};
if (gerritUtil.checkCredentials(ProjectManager.getInstance().getDefaultProject(), gerritAuthData)) {
Messages.showInfoMessage(pane, "Connection successful", "Success");
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2021 Urs Wolfer
*
* 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.urswolfer.intellij.plugin.gerrit.ui.filter;

/**
* @author Urs Wolfer
*/
public class AttentionFilter extends AbstractUserFilter {
@Override
public String getActionLabel() {
return "Attention";
}

@Override
public String getQueryField() {
return "attention";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected void configure() {
filters.addBinding().to(BranchFilter.class);
filters.addBinding().to(AssigneeFilter.class);
filters.addBinding().to(ReviewerFilter.class);
filters.addBinding().to(AttentionFilter.class);
filters.addBinding().to(OwnerFilter.class);
filters.addBinding().to(IsStarredFilter.class);

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
href="https://github.com/uwolfer/gerrit-intellij-plugin#pre-releases">
https://github.com/uwolfer/gerrit-intellij-plugin#pre-releases</a>.</li>
<li>1.2.5</li>
<ul>
<li>add "Unmark Private" to push dialog</li>
<li>add "Attention" filter</li>
<li>add support for recent IntelliJ 2021.2 builds</li>
<li>minor fixes and improvements</li>
</ul>
<li>1.2.4</li>
<ul>
<li>fix assertion error in logs when running some Git operations</li>
Expand Down

0 comments on commit 0ea96c1

Please sign in to comment.