Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2011-05-07 17:55:08 +0000
committerfbecker2011-05-07 17:55:08 +0000
commite251a5810d22e99bbf2af15c607974c90557df78 (patch)
tree93f18509a4f73f5c30550f88dd8a38a3ee6a9e8a /org.eclipse.mylyn.bugzilla.ui
parent452dad0a1eddffaf3b7f5ac265c3978ade84045d (diff)
downloadorg.eclipse.mylyn.tasks-e251a5810d22e99bbf2af15c607974c90557df78.tar.gz
org.eclipse.mylyn.tasks-e251a5810d22e99bbf2af15c607974c90557df78.tar.xz
org.eclipse.mylyn.tasks-e251a5810d22e99bbf2af15c607974c90557df78.zip
ASSIGNED - bug 345056: disable the submit button if we know that we get an error
https://bugs.eclipse.org/bugs/show_bug.cgi?id=345056
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java74
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties2
3 files changed, 77 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
index e90ab2530..8dbe62b39 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
@@ -20,8 +20,12 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField;
@@ -35,8 +39,12 @@ import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorActionPart;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
import org.eclipse.mylyn.tasks.core.data.TaskData;
@@ -45,6 +53,7 @@ import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener;
import org.eclipse.mylyn.tasks.core.sync.SubmitJobEvent;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
@@ -53,6 +62,7 @@ import org.eclipse.mylyn.tasks.ui.editors.LayoutHint;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
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;
@@ -299,6 +309,7 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
protected void createParts() {
attributeEditorMap.clear();
super.createParts();
+ testCanSubmit();
}
@Override
@@ -366,10 +377,8 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
for (String option : optionValues) {
attributeComponent.putOption(option, option);
}
- if (optionValues.size() == 1) {
+ if (optionValues.size() > 0) {
attributeComponent.setValue(optionValues.get(0));
- } else {
- attributeComponent.setValue(""); //$NON-NLS-1$
}
refresh(attributeComponent);
}
@@ -481,4 +490,63 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
super.handleTaskSubmitted(event);
}
}
+
+ @Override
+ public void refresh() {
+ super.refresh();
+ testCanSubmit();
+ }
+
+ private void testCanSubmit() {
+ final TaskRepository taskRepository = getModel().getTaskRepository();
+ AuthenticationCredentials cred = taskRepository.getCredentials(AuthenticationType.REPOSITORY);
+ if (cred == null || cred.getUserName() == null || cred.getUserName().equals("")) { //$NON-NLS-1$
+ getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Anonymous_can_not_submit_Tasks,
+ IMessageProvider.WARNING, new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ TasksUiUtil.openEditRepositoryWizard(taskRepository);
+ refresh();
+ }
+ });
+ disableSubmit();
+ return;
+ }
+ if (!getModel().getTaskData().isNew()) {
+ TaskAttribute exporter = getModel().getTaskData()
+ .getRoot()
+ .getAttribute(BugzillaAttribute.EXPORTER_NAME.getKey());
+ if (exporter == null) {
+ getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_submit_disabled_please_refresh,
+ IMessageProvider.WARNING, new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ ITask task = getModel().getTask();
+ AbstractRepositoryConnector connector = TasksUi.getRepositoryManager()
+ .getRepositoryConnector(task.getConnectorKind());
+ if (connector == null) {
+ return;
+ }
+ TasksUiInternal.synchronizeTask(connector, task, true, new JobChangeAdapter() {
+ @Override
+ public void done(IJobChangeEvent event) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ getTaskEditor().refreshPages();
+ } finally {
+ if (getTaskEditor() != null) {
+ getTaskEditor().showBusy(false);
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+ });
+ disableSubmit();
+ }
+ }
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
index d6f2cbff1..b245f2c4f 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
@@ -59,6 +59,8 @@ public class Messages extends NLS {
public static String BugzillaResponseDetailDialog_Email_Line;
+ public static String BugzillaTaskEditorPage_Anonymous_can_not_submit_Tasks;
+
public static String BugzillaTaskEditorPage_Changes_Submitted_Message;
public static String BugzillaTaskEditorPage_Please_enter_a_description_before_submitting;
@@ -69,6 +71,8 @@ public class Messages extends NLS {
public static String BugzillaTaskEditorPage_Please_enter_a_bugid_for_duplicate_of_before_submitting;
+ public static String BugzillaTaskEditorPage_submit_disabled_please_refresh;
+
public static String BugzillaVotesEditor_Show_votes;
public static String BugzillaVotesEditor_Vote;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
index af47351db..95b83a601 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
@@ -27,11 +27,13 @@ BugzillaResponseDetailDialog_Titel=submitted Changes Details
BugzillaResponseDetailDialog_Bug_Line={0}\n
BugzillaResponseDetailDialog_Action_Line=\ \ \ \ \ \ \ \ {0}\n
BugzillaResponseDetailDialog_Email_Line=\ \ \ \ \ \ \ \ \ \ \ \ {0}\n
+BugzillaTaskEditorPage_Anonymous_can_not_submit_Tasks=Anonymous can not submit Tasks\!
BugzillaTaskEditorPage_Changes_Submitted_Message=Changes submitted
BugzillaTaskEditorPage_Please_enter_a_description_before_submitting=Please enter a description before submitting
BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting=Please enter a short summary before submitting
BugzillaTaskEditorPage_Please_select_a_component_before_submitting=Please select a component before submitting
BugzillaTaskEditorPage_Please_enter_a_bugid_for_duplicate_of_before_submitting=Please enter a bugid for \"duplicate of\" before submitting
+BugzillaTaskEditorPage_submit_disabled_please_refresh=submit disabled, please refresh
BugzillaVotesEditor_Show_votes=Show votes
BugzillaVotesEditor_Vote=Vote

Back to the top