|
Lines 11-26
Link Here
|
| 11 |
|
11 |
|
| 12 |
package org.eclipse.mylyn.internal.bugzilla.ui.editor; |
12 |
package org.eclipse.mylyn.internal.bugzilla.ui.editor; |
| 13 |
|
13 |
|
|
|
14 |
import java.util.Collections; |
| 15 |
import java.util.List; |
| 14 |
import java.util.Set; |
16 |
import java.util.Set; |
| 15 |
|
17 |
|
| 16 |
import org.eclipse.core.runtime.CoreException; |
18 |
import org.eclipse.core.runtime.CoreException; |
|
|
19 |
import org.eclipse.core.runtime.NullProgressMonitor; |
| 17 |
import org.eclipse.jface.dialogs.IMessageProvider; |
20 |
import org.eclipse.jface.dialogs.IMessageProvider; |
| 18 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; |
21 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; |
| 19 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
22 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
| 20 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField; |
23 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField; |
| 21 |
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; |
24 |
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; |
|
|
25 |
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration; |
| 22 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
26 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
| 23 |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
27 |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
|
|
28 |
import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent; |
| 29 |
import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener; |
| 24 |
import org.eclipse.mylyn.tasks.ui.TasksUi; |
30 |
import org.eclipse.mylyn.tasks.ui.TasksUi; |
| 25 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor; |
31 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor; |
| 26 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage; |
32 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage; |
|
Lines 94-105
Link Here
|
| 94 |
return descriptors; |
100 |
return descriptors; |
| 95 |
} |
101 |
} |
| 96 |
|
102 |
|
|
|
103 |
private TaskDataModelListener productListener = null; |
| 104 |
|
| 97 |
@Override |
105 |
@Override |
| 98 |
protected AttributeEditorFactory createAttributeEditorFactory() { |
106 |
protected AttributeEditorFactory createAttributeEditorFactory() { |
| 99 |
AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository(), getEditorSite()) { |
107 |
AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository(), getEditorSite()) { |
| 100 |
@Override |
108 |
@Override |
| 101 |
public AbstractAttributeEditor createEditor(String type, final TaskAttribute taskAttribute) { |
109 |
public AbstractAttributeEditor createEditor(String type, final TaskAttribute taskAttribute) { |
| 102 |
AbstractAttributeEditor editor; |
110 |
AbstractAttributeEditor editor; |
|
|
111 |
if (taskAttribute.getId().equals(BugzillaAttribute.PRODUCT.getKey())) { |
| 112 |
if (productListener == null) { |
| 113 |
productListener = new TaskDataModelListener() { |
| 114 |
@Override |
| 115 |
public void attributeChanged(TaskDataModelEvent event) { |
| 116 |
TaskAttribute taskAttribute = event.getTaskAttribute(); |
| 117 |
if (taskAttribute != null) { |
| 118 |
if (taskAttribute.getId().equals(BugzillaAttribute.PRODUCT.getKey())) { |
| 119 |
RepositoryConfiguration repositoryConfiguration = null; |
| 120 |
try { |
| 121 |
repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration( |
| 122 |
getModel().getTaskRepository(), false, new NullProgressMonitor()); |
| 123 |
TaskAttribute attributeComponent = taskAttribute.getTaskData() |
| 124 |
.getRoot() |
| 125 |
.getMappedAttribute(BugzillaAttribute.COMPONENT.getKey()); |
| 126 |
TaskAttribute attributeTargetMilestone = taskAttribute.getTaskData() |
| 127 |
.getRoot() |
| 128 |
.getMappedAttribute(BugzillaAttribute.TARGET_MILESTONE.getKey()); |
| 129 |
TaskAttribute attributeDefaultAssignee = taskAttribute.getTaskData() |
| 130 |
.getRoot() |
| 131 |
.getMappedAttribute(BugzillaAttribute.SET_DEFAULT_ASSIGNEE.getKey()); |
| 132 |
|
| 133 |
if (attributeComponent != null) { |
| 134 |
List<String> optionValues = repositoryConfiguration.getComponents(taskAttribute.getValue()); |
| 135 |
Collections.sort(optionValues); |
| 136 |
attributeComponent.clearOptions(); |
| 137 |
for (String option : optionValues) { |
| 138 |
attributeComponent.putOption(option, option); |
| 139 |
} |
| 140 |
if (optionValues.size() == 1) { |
| 141 |
attributeComponent.setValue(optionValues.get(0)); |
| 142 |
} else { |
| 143 |
attributeComponent.setValue(""); //$NON-NLS-1$ |
| 144 |
} |
| 145 |
BugzillaTaskEditorPage.this.getEditorForAttribute(attributeComponent) |
| 146 |
.refresh(); |
| 147 |
} |
| 148 |
if (attributeTargetMilestone != null) { |
| 149 |
List<String> optionValues = repositoryConfiguration.getTargetMilestones(taskAttribute.getValue()); |
| 150 |
Collections.sort(optionValues); |
| 151 |
attributeTargetMilestone.clearOptions(); |
| 152 |
for (String option : optionValues) { |
| 153 |
attributeTargetMilestone.putOption(option, option); |
| 154 |
} |
| 155 |
if (optionValues.size() == 1) { |
| 156 |
attributeTargetMilestone.setValue(optionValues.get(0)); |
| 157 |
} else { |
| 158 |
attributeTargetMilestone.setValue("---"); //$NON-NLS-1$ |
| 159 |
} |
| 160 |
BugzillaTaskEditorPage.this.getEditorForAttribute( |
| 161 |
attributeTargetMilestone).refresh(); |
| 162 |
} |
| 163 |
if (attributeDefaultAssignee != null) { |
| 164 |
attributeDefaultAssignee.setValue("1"); //$NON-NLS-1$ |
| 165 |
BugzillaTaskEditorPage.this.getEditorForAttribute( |
| 166 |
attributeDefaultAssignee).refresh(); |
| 167 |
} |
| 168 |
} catch (CoreException e) { |
| 169 |
// TODO Auto-generated catch block |
| 170 |
e.printStackTrace(); |
| 171 |
} |
| 172 |
} |
| 173 |
} |
| 174 |
} |
| 175 |
}; |
| 176 |
getModel().addModelListener(productListener); |
| 177 |
} |
| 178 |
} |
| 103 |
if (IBugzillaConstants.EDITOR_TYPE_KEYWORDS.equals(type)) { |
179 |
if (IBugzillaConstants.EDITOR_TYPE_KEYWORDS.equals(type)) { |
| 104 |
editor = new BugzillaKeywordAttributeEditor(getModel(), taskAttribute); |
180 |
editor = new BugzillaKeywordAttributeEditor(getModel(), taskAttribute); |
| 105 |
} else if (IBugzillaConstants.EDITOR_TYPE_REMOVECC.equals(type)) { |
181 |
} else if (IBugzillaConstants.EDITOR_TYPE_REMOVECC.equals(type)) { |
|
Lines 125-130
Link Here
|
| 125 |
}); |
201 |
}); |
| 126 |
} |
202 |
} |
| 127 |
|
203 |
|
|
|
204 |
BugzillaTaskEditorPage.this.addToAttributeEditorMap(taskAttribute, editor); |
| 128 |
return editor; |
205 |
return editor; |
| 129 |
} |
206 |
} |
| 130 |
}; |
207 |
}; |
|
Lines 136-142
Link Here
|
| 136 |
|
213 |
|
| 137 |
TaskAttribute summaryAttribute = getModel().getTaskData().getRoot().getMappedAttribute(TaskAttribute.SUMMARY); |
214 |
TaskAttribute summaryAttribute = getModel().getTaskData().getRoot().getMappedAttribute(TaskAttribute.SUMMARY); |
| 138 |
if (summaryAttribute != null && summaryAttribute.getValue().length() == 0) { |
215 |
if (summaryAttribute != null && summaryAttribute.getValue().length() == 0) { |
| 139 |
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting, IMessageProvider.ERROR); |
216 |
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting, |
|
|
217 |
IMessageProvider.ERROR); |
| 140 |
AbstractTaskEditorPart part = getPart(ID_PART_SUMMARY); |
218 |
AbstractTaskEditorPart part = getPart(ID_PART_SUMMARY); |
| 141 |
if (part != null) { |
219 |
if (part != null) { |
| 142 |
part.setFocus(); |
220 |
part.setFocus(); |
|
Lines 147-153
Link Here
|
| 147 |
TaskAttribute componentAttribute = getModel().getTaskData().getRoot().getMappedAttribute( |
225 |
TaskAttribute componentAttribute = getModel().getTaskData().getRoot().getMappedAttribute( |
| 148 |
BugzillaAttribute.COMPONENT.getKey()); |
226 |
BugzillaAttribute.COMPONENT.getKey()); |
| 149 |
if (componentAttribute != null && componentAttribute.getValue().length() == 0) { |
227 |
if (componentAttribute != null && componentAttribute.getValue().length() == 0) { |
| 150 |
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_select_a_component_before_submitting, IMessageProvider.ERROR); |
228 |
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_select_a_component_before_submitting, |
|
|
229 |
IMessageProvider.ERROR); |
| 151 |
AbstractTaskEditorPart part = getPart(ID_PART_ATTRIBUTES); |
230 |
AbstractTaskEditorPart part = getPart(ID_PART_ATTRIBUTES); |
| 152 |
if (part != null) { |
231 |
if (part != null) { |
| 153 |
part.setFocus(); |
232 |
part.setFocus(); |
|
Lines 158-164
Link Here
|
| 158 |
TaskAttribute descriptionAttribute = getModel().getTaskData().getRoot().getMappedAttribute( |
237 |
TaskAttribute descriptionAttribute = getModel().getTaskData().getRoot().getMappedAttribute( |
| 159 |
TaskAttribute.DESCRIPTION); |
238 |
TaskAttribute.DESCRIPTION); |
| 160 |
if (descriptionAttribute != null && descriptionAttribute.getValue().length() == 0) { |
239 |
if (descriptionAttribute != null && descriptionAttribute.getValue().length() == 0) { |
| 161 |
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_enter_a_description_before_submitting, IMessageProvider.ERROR); |
240 |
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_enter_a_description_before_submitting, |
|
|
241 |
IMessageProvider.ERROR); |
| 162 |
AbstractTaskEditorPart descriptionPart = getPart(ID_PART_DESCRIPTION); |
242 |
AbstractTaskEditorPart descriptionPart = getPart(ID_PART_DESCRIPTION); |
| 163 |
if (descriptionPart != null) { |
243 |
if (descriptionPart != null) { |
| 164 |
descriptionPart.setFocus(); |
244 |
descriptionPart.setFocus(); |