Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-08-17 22:51:06 +0000
committerKevin Sawicki2011-08-17 22:51:06 +0000
commit78207428e3aadb8317d98a122802582316423d27 (patch)
treec092651eec58d532c92a9dffb4f2d36f0bcf587e /org.eclipse.mylyn.github.ui/src/org/eclipse
parent8408c5ed89efcefbbcd886107ed4c5ea657d465e (diff)
downloadegit-github-78207428e3aadb8317d98a122802582316423d27.tar.gz
egit-github-78207428e3aadb8317d98a122802582316423d27.tar.xz
egit-github-78207428e3aadb8317d98a122802582316423d27.zip
Forward query page completeness to search container.
Corrects the enablement of the Search button when query pages are used in a search container. Change-Id: Ie9bd42d3b67ceda2dfa510a33c48752dd201dd06 Signed-off-by: Kevin Sawicki <kevin@github.com>
Diffstat (limited to 'org.eclipse.mylyn.github.ui/src/org/eclipse')
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/GitHubRepositoryQueryPage.java49
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java33
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueRepositoryQueryPage.java46
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/pr/PullRequestRepositoryQueryPage.java13
4 files changed, 99 insertions, 42 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/GitHubRepositoryQueryPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/GitHubRepositoryQueryPage.java
new file mode 100644
index 00000000..d0ab17a2
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/GitHubRepositoryQueryPage.java
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.mylyn.internal.github.ui;
+
+import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
+
+/**
+ * Base repository query page
+ */
+public abstract class GitHubRepositoryQueryPage extends
+ AbstractRepositoryQueryPage {
+
+ /**
+ * @param pageName
+ * @param taskRepository
+ */
+ public GitHubRepositoryQueryPage(String pageName,
+ TaskRepository taskRepository) {
+ super(pageName, taskRepository);
+ }
+
+ /**
+ * @param pageName
+ * @param taskRepository
+ * @param query
+ */
+ public GitHubRepositoryQueryPage(String pageName,
+ TaskRepository taskRepository, IRepositoryQuery query) {
+ super(pageName, taskRepository, query);
+ }
+
+ public void setPageComplete(boolean complete) {
+ super.setPageComplete(complete);
+ // Forward completeness to search container if applicable
+ if (inSearchContainer())
+ getSearchContainer().setPerformActionEnabled(complete);
+ }
+
+}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java
index 0507d63b..2f81178c 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java
@@ -72,12 +72,14 @@ public class GistRepositoryQueryPage extends AbstractRepositoryQueryPage {
}
};
- new Label(displayArea, SWT.NONE)
- .setText(Messages.GistRepositoryQueryPage_LabelTitle);
- titleText = new Text(displayArea, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults().grab(true, false).applyTo(titleText);
- titleText.addModifyListener(completeListener);
- titleText.setFocus();
+ if (!inSearchContainer()) {
+ new Label(displayArea, SWT.NONE)
+ .setText(Messages.GistRepositoryQueryPage_LabelTitle);
+ titleText = new Text(displayArea, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(titleText);
+ titleText.addModifyListener(completeListener);
+ titleText.setFocus();
+ }
new Label(displayArea, SWT.NONE)
.setText(Messages.GistRepositoryQueryPage_LabelUser);
@@ -87,13 +89,11 @@ public class GistRepositoryQueryPage extends AbstractRepositoryQueryPage {
IRepositoryQuery query = getQuery();
if (query != null) {
- if (query.getSummary() != null)
+ if (titleText != null && query.getSummary() != null)
titleText.setText(query.getSummary());
if (query.getAttribute(IGistQueryConstants.USER) != null)
userText.setText(query.getAttribute(IGistQueryConstants.USER));
- } else if (TasksUiPlugin.getTaskList()
- .getRepositoryQueries(getTaskRepository().getRepositoryUrl())
- .isEmpty()) {
+ } else if (!inSearchContainer() && !hasQueries()) {
titleText.setText(Messages.GistRepositoryQueryPage_TitleDefault);
AuthenticationCredentials credentials = getTaskRepository()
.getCredentials(AuthenticationType.REPOSITORY);
@@ -107,20 +107,27 @@ public class GistRepositoryQueryPage extends AbstractRepositoryQueryPage {
}
/**
+ * @return true if queries existing for this repository, false otherwise
+ */
+ protected boolean hasQueries() {
+ String url = getTaskRepository().getRepositoryUrl();
+ return !TasksUiPlugin.getTaskList().getRepositoryQueries(url).isEmpty();
+ }
+
+ /**
* @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage#getQueryTitle()
*/
public String getQueryTitle() {
- return this.titleText.getText();
+ return titleText != null ? titleText.getText() : null;
}
/**
* @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage#isPageComplete()
*/
public boolean isPageComplete() {
- boolean complete = super.isPageComplete();
+ boolean complete = inSearchContainer() ? true : super.isPageComplete();
if (complete)
complete = userText.getText().trim().length() > 0;
-
return complete;
}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueRepositoryQueryPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueRepositoryQueryPage.java
index b8447ced..b354bb28 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueRepositoryQueryPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueRepositoryQueryPage.java
@@ -37,12 +37,12 @@ import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.internal.github.core.QueryUtils;
import org.eclipse.mylyn.internal.github.core.issue.IssueConnector;
import org.eclipse.mylyn.internal.github.ui.GitHubImages;
+import org.eclipse.mylyn.internal.github.ui.GitHubRepositoryQueryPage;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
import org.eclipse.mylyn.internal.provisional.commons.ui.ICoreRunnable;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
-import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@@ -65,7 +65,7 @@ import org.eclipse.ui.PlatformUI;
/**
* GitHub issue repository query page class.
*/
-public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
+public class IssueRepositoryQueryPage extends GitHubRepositoryQueryPage {
private Button openButton;
private Button closedButton;
@@ -149,12 +149,12 @@ public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
openButton = new Button(statusArea, SWT.CHECK);
openButton.setSelection(true);
openButton.setText(Messages.IssueRepositoryQueryPage_StatusOpen);
- openButton.addSelectionListener(this.completeListener);
+ openButton.addSelectionListener(completeListener);
closedButton = new Button(statusArea, SWT.CHECK);
closedButton.setSelection(true);
closedButton.setText(Messages.IssueRepositoryQueryPage_StatusClosed);
- closedButton.addSelectionListener(this.completeListener);
+ closedButton.addSelectionListener(completeListener);
ToolBar toolbar = new ToolBar(statusArea, SWT.FLAT);
ToolItem updateItem = new ToolItem(toolbar, SWT.PUSH);
@@ -245,13 +245,13 @@ public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
String milestoneNumber = query
.getAttribute(IssueService.FILTER_MILESTONE);
- if (milestoneNumber != null && this.milestones != null) {
+ if (milestoneNumber != null && milestones != null) {
int index = 0;
- for (Milestone milestone : this.milestones) {
+ for (Milestone milestone : milestones) {
index++;
if (milestoneNumber.equals(Integer.toString(milestone
.getNumber()))) {
- this.milestoneCombo.select(index);
+ milestoneCombo.select(index);
break;
}
}
@@ -275,7 +275,7 @@ public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
}
private boolean updateLabels() {
- if (this.labelsViewer.getControl().isDisposed())
+ if (labelsViewer.getControl().isDisposed())
return false;
IssueConnector connector = IssueConnectorUi.getCoreConnector();
@@ -288,33 +288,32 @@ public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
List<String> labelNames = new ArrayList<String>(labels.size());
for (org.eclipse.egit.github.core.Label label : labels)
labelNames.add(label.getName());
- this.labelsViewer.setInput(labelNames);
+ labelsViewer.setInput(labelNames);
}
return hasLabels;
}
private boolean updateMilestones() {
- if (this.milestoneCombo.isDisposed())
+ if (milestoneCombo.isDisposed())
return false;
IssueConnector connector = IssueConnectorUi.getCoreConnector();
TaskRepository repository = getTaskRepository();
boolean hasMilestones = connector.hasCachedMilestones(repository);
if (hasMilestones) {
- this.milestones = connector.getMilestones(repository);
- this.milestoneCombo.removeAll();
- this.milestoneCombo
- .add(Messages.IssueRepositoryQueryPage_MilestoneNone);
- Collections.sort(this.milestones, new Comparator<Milestone>() {
+ milestones = connector.getMilestones(repository);
+ milestoneCombo.removeAll();
+ milestoneCombo.add(Messages.IssueRepositoryQueryPage_MilestoneNone);
+ Collections.sort(milestones, new Comparator<Milestone>() {
public int compare(Milestone m1, Milestone m2) {
return m1.getTitle().compareToIgnoreCase(m2.getTitle());
}
});
for (Milestone milestone : milestones)
- this.milestoneCombo.add(milestone.getTitle());
+ milestoneCombo.add(milestone.getTitle());
- this.milestoneCombo.select(0);
+ milestoneCombo.select(0);
}
return hasMilestones;
}
@@ -375,7 +374,7 @@ public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
* @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage#isPageComplete()
*/
public boolean isPageComplete() {
- boolean complete = super.isPageComplete();
+ boolean complete = inSearchContainer() ? true : super.isPageComplete();
if (complete) {
String message = null;
if (!openButton.getSelection() && !closedButton.getSelection())
@@ -391,7 +390,7 @@ public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
* @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage#getQueryTitle()
*/
public String getQueryTitle() {
- return this.titleText != null ? this.titleText.getText() : null;
+ return titleText != null ? titleText.getText() : null;
}
/**
@@ -407,23 +406,22 @@ public class IssueRepositoryQueryPage extends AbstractRepositoryQueryPage {
statuses.add(IssueService.STATE_CLOSED);
QueryUtils.setAttribute(IssueService.FILTER_STATE, statuses, query);
- String assignee = this.assigneeText.getText().trim();
+ String assignee = assigneeText.getText().trim();
if (assignee.length() > 0)
query.setAttribute(IssueService.FILTER_ASSIGNEE, assignee);
else
query.setAttribute(IssueService.FILTER_ASSIGNEE, null);
- String mentions = this.mentionText.getText().trim();
+ String mentions = mentionText.getText().trim();
if (mentions.length() > 0)
query.setAttribute(IssueService.FILTER_MENTIONED, mentions);
else
query.setAttribute(IssueService.FILTER_MENTIONED, null);
- int milestoneSelected = this.milestoneCombo.getSelectionIndex() - 1;
+ int milestoneSelected = milestoneCombo.getSelectionIndex() - 1;
if (milestoneSelected >= 0)
query.setAttribute(IssueService.FILTER_MILESTONE, Integer
- .toString(this.milestones.get(milestoneSelected)
- .getNumber()));
+ .toString(milestones.get(milestoneSelected).getNumber()));
else
query.setAttribute(IssueService.FILTER_MILESTONE, null);
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/pr/PullRequestRepositoryQueryPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/pr/PullRequestRepositoryQueryPage.java
index 164b56ab..57def36e 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/pr/PullRequestRepositoryQueryPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/pr/PullRequestRepositoryQueryPage.java
@@ -17,9 +17,9 @@ import org.eclipse.egit.github.core.service.IssueService;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.mylyn.internal.github.core.QueryUtils;
+import org.eclipse.mylyn.internal.github.ui.GitHubRepositoryQueryPage;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.Text;
/**
* GitHub pull request repository query page class.
*/
-public class PullRequestRepositoryQueryPage extends AbstractRepositoryQueryPage {
+public class PullRequestRepositoryQueryPage extends GitHubRepositoryQueryPage {
private Button openButton;
private Button closedButton;
@@ -80,7 +80,8 @@ public class PullRequestRepositoryQueryPage extends AbstractRepositoryQueryPage
GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
.applyTo(statusArea);
- new Label(statusArea, SWT.NONE).setText(Messages.PullRequestRepositoryQueryPage_LabelStatus);
+ new Label(statusArea, SWT.NONE)
+ .setText(Messages.PullRequestRepositoryQueryPage_LabelStatus);
openButton = new Button(statusArea, SWT.CHECK);
openButton.setSelection(true);
@@ -89,7 +90,8 @@ public class PullRequestRepositoryQueryPage extends AbstractRepositoryQueryPage
closedButton = new Button(statusArea, SWT.CHECK);
closedButton.setSelection(true);
- closedButton.setText(Messages.PullRequestRepositoryQueryPage_StatusClosed);
+ closedButton
+ .setText(Messages.PullRequestRepositoryQueryPage_StatusClosed);
closedButton.addSelectionListener(this.completeListener);
}
@@ -108,7 +110,8 @@ public class PullRequestRepositoryQueryPage extends AbstractRepositoryQueryPage
GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
.applyTo(titleArea);
- new Label(titleArea, SWT.NONE).setText(Messages.PullRequestRepositoryQueryPage_LabelTitle);
+ new Label(titleArea, SWT.NONE)
+ .setText(Messages.PullRequestRepositoryQueryPage_LabelTitle);
titleText = new Text(titleArea, SWT.SINGLE | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(titleText);
titleText.addModifyListener(new ModifyListener() {

Back to the top