aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-26 12:28:18 (EDT)
committerChris Aniszczyk2011-05-05 20:23:54 (EDT)
commita50b21285bb3f65956b5edf756f3f65d1a16e394 (patch)
tree7b3b1b631417adb9393f0eb3817f67e6eacf8bcc
parent59bfd0df475f9036c408a4dc310862c33499eeb8 (diff)
downloadegit-github-a50b21285bb3f65956b5edf756f3f65d1a16e394.zip
egit-github-a50b21285bb3f65956b5edf756f3f65d1a16e394.tar.gz
egit-github-a50b21285bb3f65956b5edf756f3f65d1a16e394.tar.bz2
Add update milestones and labels button to query pagerefs/changes/59/3259/2
Change-Id: Ic8de4156566229d4cb9764d0b401d980f8e8130f Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryQueryPage.java196
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/Messages.java3
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/messages.properties1
3 files changed, 121 insertions, 79 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryQueryPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryQueryPage.java
index 090423d..1a2d941 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryQueryPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubRepositoryQueryPage.java
@@ -12,9 +12,9 @@
*******************************************************************************/
package org.eclipse.mylyn.github.ui.internal;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
@@ -24,7 +24,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -36,10 +36,15 @@ import org.eclipse.mylyn.github.internal.IssueService;
import org.eclipse.mylyn.github.internal.LabelComparator;
import org.eclipse.mylyn.github.internal.Milestone;
import org.eclipse.mylyn.github.internal.QueryUtils;
+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;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
@@ -52,6 +57,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.PlatformUI;
/**
@@ -124,39 +131,13 @@ public class GitHubRepositoryQueryPage extends AbstractRepositoryQueryPage {
});
}
- /**
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- Composite displayArea = new Composite(parent, SWT.NONE);
- GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false)
- .applyTo(displayArea);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(displayArea);
-
- if (!inSearchContainer()) {
- Composite titleArea = new Composite(displayArea, SWT.NONE);
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(titleArea);
- GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
- .applyTo(titleArea);
-
- new Label(titleArea, SWT.NONE)
- .setText(Messages.GitHubRepositoryQueryPage_TitleLabel);
- titleText = new Text(titleArea, SWT.SINGLE | SWT.BORDER);
- GridDataFactory.fillDefaults().grab(true, false).applyTo(titleText);
- titleText.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- setPageComplete(isPageComplete());
- }
- });
- }
-
- Composite leftArea = new Composite(displayArea, SWT.NONE);
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(leftArea);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(leftArea);
+ private void createOptionsArea(Composite parent) {
+ Composite optionsArea = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(optionsArea);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(optionsArea);
- Composite statusArea = new Composite(leftArea, SWT.NONE);
- GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false)
+ Composite statusArea = new Composite(optionsArea, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(4).equalWidth(false)
.applyTo(statusArea);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
.applyTo(statusArea);
@@ -174,26 +155,80 @@ public class GitHubRepositoryQueryPage extends AbstractRepositoryQueryPage {
closedButton.setText(Messages.GitHubRepositoryQueryPage_StatusClosed);
closedButton.addSelectionListener(this.completeListener);
- Label milestonesLabel = new Label(leftArea, SWT.NONE);
+ ToolBar toolbar = new ToolBar(statusArea, SWT.FLAT);
+ ToolItem updateItem = new ToolItem(toolbar, SWT.PUSH);
+ final Image updateImage = TasksUiImages.REPOSITORY_UPDATE_CONFIGURATION
+ .createImage();
+ toolbar.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ updateImage.dispose();
+ }
+ });
+ updateItem.setImage(updateImage);
+ updateItem
+ .setToolTipText(Messages.GitHubRepositoryQueryPage_TooltipUpdateRepository);
+ GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL)
+ .grab(true, false).applyTo(toolbar);
+ updateItem.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ refreshRepository();
+ }
+
+ });
+
+ Label milestonesLabel = new Label(optionsArea, SWT.NONE);
milestonesLabel
.setText(Messages.GitHubRepositoryQueryPage_MilestoneLabel);
- milestoneCombo = new Combo(leftArea, SWT.DROP_DOWN | SWT.READ_ONLY);
+ milestoneCombo = new Combo(optionsArea, SWT.DROP_DOWN | SWT.READ_ONLY);
GridDataFactory.fillDefaults().grab(true, false)
.applyTo(milestoneCombo);
- Label assigneeLabel = new Label(leftArea, SWT.NONE);
+ Label assigneeLabel = new Label(optionsArea, SWT.NONE);
assigneeLabel.setText(Messages.GitHubRepositoryQueryPage_AssigneeLabel);
- assigneeText = new Text(leftArea, SWT.BORDER | SWT.SINGLE);
+ assigneeText = new Text(optionsArea, SWT.BORDER | SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(assigneeText);
- Label mentionLabel = new Label(leftArea, SWT.NONE);
+ Label mentionLabel = new Label(optionsArea, SWT.NONE);
mentionLabel.setText(Messages.GitHubRepositoryQueryPage_MentionsLabel);
- mentionText = new Text(leftArea, SWT.BORDER | SWT.SINGLE);
+ mentionText = new Text(optionsArea, SWT.BORDER | SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(mentionText);
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite displayArea = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true)
+ .applyTo(displayArea);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(displayArea);
+
+ if (!inSearchContainer()) {
+ Composite titleArea = new Composite(displayArea, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(titleArea);
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
+ .applyTo(titleArea);
+
+ new Label(titleArea, SWT.NONE)
+ .setText(Messages.GitHubRepositoryQueryPage_TitleLabel);
+ titleText = new Text(titleArea, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(titleText);
+ titleText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(isPageComplete());
+ }
+ });
+ }
+
+ createOptionsArea(displayArea);
+
createLabelsArea(displayArea);
loadRepository();
@@ -271,6 +306,12 @@ public class GitHubRepositoryQueryPage extends AbstractRepositoryQueryPage {
this.milestoneCombo.removeAll();
this.milestoneCombo
.add(Messages.GitHubRepositoryQueryPage_MilestoneNone);
+ Collections.sort(this.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());
@@ -281,49 +322,46 @@ public class GitHubRepositoryQueryPage extends AbstractRepositoryQueryPage {
private void refreshRepository() {
try {
- getContainer().run(true, true, new IRunnableWithProgress() {
+ ICoreRunnable runnable = new ICoreRunnable() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
+ public void run(IProgressMonitor monitor) throws CoreException {
Policy.monitorFor(monitor);
monitor.beginTask("", 2); //$NON-NLS-1$
- try {
- GitHubRepositoryConnector connector = GitHubRepositoryConnectorUI
- .getCoreConnector();
- TaskRepository repository = getTaskRepository();
-
- monitor.setTaskName(Messages.GitHubRepositoryQueryPage_TaskLoadingLabels);
- connector.refreshLabels(repository);
- monitor.worked(1);
-
- monitor.setTaskName(Messages.GitHubRepositoryQueryPage_TaskLoadingMilestones);
- connector.refreshMilestones(repository);
- monitor.done();
-
- PlatformUI.getWorkbench().getDisplay()
- .asyncExec(new Runnable() {
-
- public void run() {
- updateLabels();
- updateMilestones();
- initialize();
- }
- });
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
+ GitHubRepositoryConnector connector = GitHubRepositoryConnectorUI
+ .getCoreConnector();
+ TaskRepository repository = getTaskRepository();
+
+ monitor.setTaskName(Messages.GitHubRepositoryQueryPage_TaskLoadingLabels);
+ connector.refreshLabels(repository);
+ monitor.worked(1);
+
+ monitor.setTaskName(Messages.GitHubRepositoryQueryPage_TaskLoadingMilestones);
+ connector.refreshMilestones(repository);
+ monitor.done();
+
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(new Runnable() {
+
+ public void run() {
+ updateLabels();
+ updateMilestones();
+ initialize();
+ }
+ });
}
- });
- } catch (InvocationTargetException e) {
- Throwable target = e.getTargetException();
- if (target instanceof CoreException) {
- IStatus status = ((CoreException) target).getStatus();
- ErrorDialog.openError(getShell(),
- Messages.GitHubRepositoryQueryPage_ErrorLoading,
- target.getLocalizedMessage(), status);
- }
- } catch (InterruptedException ignore) {
- // Ignore
+ };
+ IRunnableContext context = getContainer();
+ if (context == null)
+ if (inSearchContainer())
+ context = getSearchContainer().getRunnableContext();
+ else
+ context = PlatformUI.getWorkbench().getProgressService();
+ CommonUiUtil.run(context, runnable);
+ } catch (CoreException e) {
+ IStatus status = e.getStatus();
+ ErrorDialog.openError(getShell(),
+ Messages.GitHubRepositoryQueryPage_ErrorLoading,
+ e.getLocalizedMessage(), status);
}
}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/Messages.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/Messages.java
index 36251ce..9c1cc2d 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/Messages.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/Messages.java
@@ -80,6 +80,9 @@ public class Messages extends NLS {
public static String GitHubRepositoryQueryPage_TitleLabel;
/** */
+ public static String GitHubRepositoryQueryPage_TooltipUpdateRepository;
+
+ /** */
public static String GitHubRepositorySettingsPage_Description;
/** */
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/messages.properties b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/messages.properties
index dd53699..0cb0e3a 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/messages.properties
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/messages.properties
@@ -18,6 +18,7 @@ GitHubRepositoryQueryPage_StatusOpen=Open
GitHubRepositoryQueryPage_TaskLoadingLabels=Loading labels
GitHubRepositoryQueryPage_TaskLoadingMilestones=Loading milestones
GitHubRepositoryQueryPage_TitleLabel=Title:
+GitHubRepositoryQueryPage_TooltipUpdateRepository=Update milestones and labels
GitHubRepositorySettingsPage_Description=Enter repository location and credentials
GitHubRepositorySettingsPage_StatusError=Error validating settings: {0}
GitHubRepositorySettingsPage_ErrorMalformedUrl=Server URL must be in the form http://github.com/user/project