Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaloyan Raev2012-10-08 09:14:47 +0000
committerMatthias Sohn2012-11-30 00:22:37 +0000
commit18e3905a98c4dca006f3467bbd4fc1737e9b0cf9 (patch)
tree9d69ba775cccd7b799d6a7529af15ceb35fe4c10 /org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn
parente95c6e108300cc39e4de77f5f0014e40c5068e9e (diff)
downloadegit-github-18e3905a98c4dca006f3467bbd4fc1737e9b0cf9.tar.gz
egit-github-18e3905a98c4dca006f3467bbd4fc1737e9b0cf9.tar.xz
egit-github-18e3905a98c4dca006f3467bbd4fc1737e9b0cf9.zip
Show info message that anonymous cannot submit tasks
When creating or refreshing the editor, it is checked if the github repository is configured with user credentials. In case, it is anonymous an info message is shown. When clicking on the info message, the repository configuration dialog is opened and the user can enter the credentials. If the repository is anonymous and the user insists to submit the issue, then the info message turns into error message. This solution is inspired by the Bugzilla task editor. Bug: 390757 Change-Id: I9f498acdec46a15156939e71bcc9bd40766cd65f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn')
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueTaskEditorPage.java51
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/Messages.java4
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/messages.properties1
3 files changed, 55 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueTaskEditorPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueTaskEditorPage.java
index e200e7f2..3c41a7b2 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueTaskEditorPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/IssueTaskEditorPage.java
@@ -9,18 +9,27 @@
* David Green <david.green@tasktop.com> - initial contribution
* Christian Trutz <christian.trutz@gmail.com> - initial contribution
* Chris Aniszczyk <caniszczyk@gmail.com> - initial contribution
+ * Kaloyan Raev <kaloyan.raev@sap.com> - bug 390757
*******************************************************************************/
package org.eclipse.mylyn.internal.github.ui.issue;
import java.util.Iterator;
import java.util.Set;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.github.core.GitHub;
import org.eclipse.mylyn.internal.github.core.issue.IssueAttribute;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
/**
* Editor page for GitHub.
@@ -29,7 +38,7 @@ public class IssueTaskEditorPage extends AbstractTaskEditorPage {
/**
* Constructor for the GitHubTaskEditorPage
- *
+ *
* @param editor
* The task editor to create for GitHub
*/
@@ -67,4 +76,44 @@ public class IssueTaskEditorPage extends AbstractTaskEditorPage {
}.setPath(PATH_ATTRIBUTES));
return partDescriptors;
}
+
+ @Override
+ protected void createParts() {
+ super.createParts();
+ checkCanSubmit(IMessageProvider.INFORMATION);
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh();
+ checkCanSubmit(IMessageProvider.INFORMATION);
+ }
+
+ @Override
+ public void doSubmit() {
+ if (!checkCanSubmit(IMessageProvider.ERROR))
+ return;
+ super.doSubmit();
+ }
+
+ private boolean checkCanSubmit(final int type) {
+ final TaskRepository taskRepository = getModel().getTaskRepository();
+ AuthenticationCredentials cred = taskRepository.getCredentials(AuthenticationType.REPOSITORY);
+ if (cred == null || cred.getUserName() == null || cred.getUserName().equals("")) { //$NON-NLS-1$
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ getTaskEditor().setMessage(Messages.IssueTaskEditorPage_MessageAnonymousCannotSubmit, type,
+ new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ TasksUiUtil.openEditRepositoryWizard(taskRepository);
+ refresh();
+ }
+ });
+ }
+ });
+ return false;
+ }
+ return true;
+ }
}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/Messages.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/Messages.java
index cec1fceb..607e53ea 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/Messages.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/Messages.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ * Kaloyan Raev <kaloyan.raev@sap.com> - bug 390757
*******************************************************************************/
package org.eclipse.mylyn.internal.github.ui.issue;
@@ -89,6 +90,9 @@ public class Messages extends NLS {
public static String IssueRepositorySettingsPage_Title;
/** */
+ public static String IssueTaskEditorPage_MessageAnonymousCannotSubmit;
+
+ /** */
public static String IssueTaskEditorPageFactory_PageText;
/** */
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/messages.properties b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/messages.properties
index ff59f489..218c5fab 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/messages.properties
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/issue/messages.properties
@@ -21,6 +21,7 @@ IssueRepositorySettingsPage_StatusSuccess=Success\!
IssueRepositorySettingsPage_TaskContactingServer=Contacting server...
IssueRepositorySettingsPage_TaskValidating=Validating settings
IssueRepositorySettingsPage_Title=GitHub Issue Repository Settings
+IssueTaskEditorPage_MessageAnonymousCannotSubmit=Anonymous cannot submit issues\!
IssueTaskEditorPageFactory_PageText=GitHub
IssueLabelAttributeEditor_ActionNewLabel=New Label...
IssueLabelAttributeEditor_ActionRemoveLabel=Remove Label

Back to the top