Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix IDEA-132015 #249

Merged
merged 1 commit into from
Mar 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public int getId() {

private String myAPIKey = "";
private RedmineProject myCurrentProject;
private boolean assignedMe = true;
private List<RedmineProject> myProjects = null;

/**
Expand All @@ -90,6 +91,7 @@ public RedmineRepository(RedmineRepository other) {
super(other);
setAPIKey(other.myAPIKey);
setCurrentProject(other.getCurrentProject());
setAssignedMe(other.isAssignedMe());
}

@Override
Expand All @@ -99,6 +101,7 @@ public boolean equals(Object o) {
RedmineRepository that = (RedmineRepository)o;
if (!Comparing.equal(getAPIKey(), that.getAPIKey())) return false;
if (!Comparing.equal(getCurrentProject(), that.getCurrentProject())) return false;
if (isAssignedMe() != that.isAssignedMe()) return false;
return true;
}

Expand Down Expand Up @@ -168,8 +171,10 @@ private URI getIssuesUrl(int offset, int limit, boolean withClosed) throws URISy
.addParameter("offset", String.valueOf(offset))
.addParameter("limit", String.valueOf(limit))
.addParameter("sort", "updated_on:desc")
.addParameter("status_id", withClosed ? "*" : "open")
.addParameter("assigned_to_id", "me");
.addParameter("status_id", withClosed ? "*" : "open");
if (assignedMe) {
builder.addParameter("assigned_to_id", "me");
}
// If project was not chosen, all available issues still fetched. Such behavior may seems strange to user.
if (myCurrentProject != null && myCurrentProject != UNSPECIFIED_PROJECT) {
builder.addParameter("project_id", String.valueOf(myCurrentProject.getId()));
Expand Down Expand Up @@ -225,6 +230,14 @@ public void setAPIKey(String APIKey) {
myAPIKey = APIKey;
}

public boolean isAssignedMe() {
return assignedMe;
}

public void setAssignedMe(boolean assignedMe) {
this.assignedMe = assignedMe;
}

private boolean isUseApiKeyAuthentication() {
return !isUseHttpAuthentication() && StringUtil.isNotEmpty(myAPIKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@
public class RedmineRepositoryEditor extends BaseRepositoryEditor<RedmineRepository> {
private ComboBox myProjectCombo;
private JTextField myAPIKey;
private JCheckBox assignedMe;
private JBLabel myProjectLabel;
private JBLabel myAPIKeyLabel;
private JBLabel assignedMeLabel;

public RedmineRepositoryEditor(final Project project, final RedmineRepository repository, Consumer<RedmineRepository> changeListener) {
super(project, repository, changeListener);

myTestButton.setEnabled(myRepository.isConfigured());
myAPIKey.setText(repository.getAPIKey());
assignedMe.setSelected(repository.isAssignedMe());

installListener(myProjectCombo);
installListener(myAPIKey);
installListener(assignedMe);

toggleCredentialsVisibility();

Expand Down Expand Up @@ -75,6 +79,7 @@ public void apply() {
RedmineProjectItem selected = (RedmineProjectItem)myProjectCombo.getSelectedItem();
myRepository.setCurrentProject(selected != null ? selected.myProject : null);
myRepository.setAPIKey(myAPIKey.getText().trim());
myRepository.setAssignedMe(assignedMe.isSelected());
myTestButton.setEnabled(myRepository.isConfigured());
toggleCredentialsVisibility();
}
Expand Down Expand Up @@ -119,9 +124,13 @@ public void customize(JList list, RedmineProjectItem value, int index, boolean s

myAPIKeyLabel = new JBLabel("API Token:", SwingConstants.RIGHT);
myAPIKey = new JPasswordField();

assignedMeLabel = new JBLabel("Assigned me:", SwingConstants.RIGHT);
assignedMe = new JCheckBox();
return FormBuilder.createFormBuilder()
.addLabeledComponent(myAPIKeyLabel, myAPIKey)
.addLabeledComponent(myProjectLabel, myProjectCombo)
.addLabeledComponent(assignedMeLabel, assignedMe)
.getPanel();
}

Expand All @@ -130,6 +139,7 @@ public void setAnchor(@Nullable final JComponent anchor) {
super.setAnchor(anchor);
myProjectLabel.setAnchor(anchor);
myAPIKeyLabel.setAnchor(anchor);
assignedMeLabel.setAnchor(anchor);
}

private static class RedmineProjectItem {
Expand Down