private class ProjectTaskDataModelListener extends TaskDataModelListener {
@Override
public void attributeChanged(TaskDataModelEvent event) {
TaskAttribute root = getModel().getTaskData().getRoot();
TaskAttribute changedAttribute = event.getTaskAttribute();
if(changedAttribute.getId().equals(RedmineAttribute.PROJECT.getTaskKey())) {
Project project = cfg.getProjects().getById(getAttributeId(RedmineAttribute.PROJECT));
if(project==null) {
getTaskEditor().setMessage(Messages.ERRMSG_UPDATING_ATTRIBUTES_FAILED, IMessageProvider.ERROR);
} else {
TaskAttribute taskAttribute = null;
Map<RedmineAttribute, List<?extends Property>> projectSpecific = new HashMap<RedmineAttribute, List<? extends Property>>(4);
projectSpecific.put(RedmineAttribute.TRACKER, cfg.getTrackers().getById(project.getTrackerIds()));
projectSpecific.put(RedmineAttribute.CATEGORY, cfg.getIssueCategories().getById(project.getIssueCategoryIds()));
projectSpecific.put(RedmineAttribute.VERSION, cfg.getVersions().getById(project.getVersionIds()));
projectSpecific.put(RedmineAttribute.ASSIGNED_TO, cfg.getUsers().getById(project.getAssignableMemberIds()));
for (Entry<RedmineAttribute, List<?extends Property>> entry : projectSpecific.entrySet()) {
taskAttribute = root.getAttribute(entry.getKey().getTaskKey());
if(taskAttribute!=null) {
taskAttribute.clearOptions();
if(!entry.getKey().isRequired()) {
taskAttribute.putOption("", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
for(Property property : entry.getValue()) {
taskAttribute.putOption(""+property.getId(), property.getName()); //$NON-NLS-1$
}
if(entry.getKey().isRequired() && entry.getValue().size()==1) {
taskAttribute.setValue(""+entry.getValue().get(0).getId()); //$NON-NLS-1$
}
refreshEditor(taskAttribute);
}
}